0

Hello Everybody there.

I wanna know if there is a command of set of commands (maybe a pipeline set) which can be used to change the hidden attribute of many files stored in a particular directory, with the same name.

ie.

ls -la inside torrents/music/david_guetta_greatest_hits shows the next files:

drwxrwxrwx  20 crsuarez  staff      680 Apr  9 19:25 .
drwxrwxrwx  20 crsuarez  staff      680 Apr  9 19:11 ..
-rw-r--r--   1 crsuarez  staff  6894561 Apr  9 19:16 .I'm Famous.wma
-rw-r--r--   1 crsuarez  staff  7543777 Apr  9 19:16 .Gettin Over.wma
-rw-r--r--   1 crsuarez  staff  6378465 Apr  9 19:16 .I Gotta Feeling.wma
-rw-r--r--   1 crsuarez  staff  7245793 Apr  9 19:16 .In love with myself.wma
-rw-r--r--   1 crsuarez  staff  7060449 Apr  9 19:16 .It's the Way You Love Me.wma
-rw-r--r--   1 crsuarez  staff  7737313 Apr  9 19:16 .Love Don't Let Me Go.wma
-rw-r--r--   1 crsuarez  staff  7737313 Apr  9 19:16 .Love is Gone.wma
-rw-r--r--   1 crsuarez  staff  6628321 Apr  9 19:16 .Memories.wma
-rw-r--r--   1 crsuarez  staff  7525345 Apr  9 19:16 .Money.wma
-rw-r--r--   1 crsuarez  staff  7806945 Apr  9 19:16 .One Love.wma
-rw-r--r--   1 crsuarez  staff  7192545 Apr  9 19:16 .Sexy Bitch.wma
-rw-r--r--   1 crsuarez  staff  6954977 Apr  9 19:16 .Stay.wma
-rw-r--r--   1 crsuarez  staff  8025057 Apr  9 19:16 .The World is Mine.wma
-rw-r--r--   1 crsuarez  staff  7769057 Apr  9 19:16 .TitaniuM.wma
-rw-r--r--   1 crsuarez  staff  6693857 Apr  9 19:16 .Turn ME ON.wma
-rw-r--r--   1 crsuarez  staff  7215073 Apr  9 19:16 .When Love Takes Over.wma
-rw-r--r--   1 crsuarez  staff  8182753 Apr  9 19:16 .Without YoU.wma

I wanna unhide all of this files with a single set of commands (I don't care if I have to use pipeline), instead of use mv .hidden_file_name not_hidden_file_name.

The solution must be OSX Complain. ;)

crsuarezf
  • 1,201
  • 3
  • 18
  • 33
  • 1
    There is no such thing as a "hidden attribute". What you seem to want to do is rename the files so that their names don't start with `.`. See [Ignacio Vazquez-Abrams](http://stackoverflow.com/users/20862/ignacio-vazquez-abrams)'s answer for one way to do that. – Celada Apr 10 '12 at 00:41
  • I forgot to mention that the solution must be OSX Compatible. :) – crsuarezf Apr 10 '12 at 00:49

2 Answers2

1

Use prename (rename on Debian-derived systems).

prename 's/^.//' .*.wma
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
1

Something like this

for origname in .[0-9A-Za-z]*
do   
    if [ -f "${origname}" ]; then
        # compute your newname how you want it
        mv "${origname}" "${newname}
    fi
done

You'll have to decide what you want your new names to be - you'll strip off the leading dot '.' but doing only what will probably collide with an existing .wma file with the same name, so maybe also append .tmp -- like:

.One Love.wma  --becomes-->  One Love.wma.tmp
Stephen P
  • 14,422
  • 2
  • 43
  • 67
  • This is perfect, i only need the pipeline. I was trying with sed, but i cannot strip off the leading dot. :S for i in .[0-9A-Za-z]* ; do echo $i | sed 'regular expresion to strip off the leading dot' ; done – crsuarezf Apr 10 '12 at 01:19
  • I had this, but i need fix the problem with the .wma :S for i in .[0-9A-Za-z]* ; do N=`echo "$i" | sed "s/\.//g"`; mv "$i" "$N" ; done – crsuarezf Apr 10 '12 at 02:01