Question

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. ;)

Was it helpful?

Solution

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

OTHER TIPS

Use prename (rename on Debian-derived systems).

prename 's/^.//' .*.wma
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top