Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

urbanforces

macrumors newbie
Original poster
Jun 11, 2013
11
1
hong kong
hello. any decent app - free or not - that can add the name of the folder files are in. i have lots of photo and video files that are all named IMG, MAH, DSC etc depending on what i used to take them and have them in folders named for specific projects or subjects i'm working on. is there an app that can just rename all the files without me having to got through each folder using finder to add each folder name. that would be a huge pain. i have googled this and can't seem to see any mac software that will do it and am not familiar enough with automator to create a script. thanks
 

960design

macrumors 68040
Apr 17, 2012
3,703
1,571
Destin, FL
...is there an app that can just rename all the files without me having to got through each folder using finder to add each folder name.
automator

i have googled this and can't seem to see any mac software that will do it and am not familiar enough with automator to create a script.
Spend a couple of minutes on youtube looking at automator tutorials. It is quite easy and will be a fantastic exercise for your brain.
 

urbanforces

macrumors newbie
Original poster
Jun 11, 2013
11
1
hong kong
automator

Spend a couple of minutes on youtube looking at automator tutorials. It is quite easy and will be a fantastic exercise for your brain.

ok will do. in the meantime, i downloaded better file rename and it has an option for "paths?". thanks
 

ChrisA

macrumors G5
Jan 5, 2006
12,601
1,737
Redondo Beach, California
hello. any decent app - free or not - that can add the name of the folder files are in. i have lots of photo and video files that are all named IMG, MAH, DSC etc depending on what i used to take them and have them in folders named for specific projects or subjects i'm working on. is there an app that can just rename all the files without me having to got through each folder using finder to add each folder name. that would be a huge pain. i have googled this and can't seem to see any mac software that will do it and am not familiar enough with automator to create a script. thanks

Skip Automator. You need a shell script in a terminal window

foreach f ( *.IMG)
mv $f $(dirname $f)_$f
end

Something like those three lines should do it. This is why you don't see software to do this. But DO NOT copy/paste the above. read the man pages first and under it yourself first.
 
Last edited:

NoBoMac

Moderator
Staff member
Jul 1, 2014
5,818
4,428
Don't think dirname will give the actual folder, will get "." for the folder.

For the default bash shell, the following will work:

Code:
fdir=$(basename `pwd`)
for f in $(ls -1 *.jpg)
do
mv "$f" "$fdir"_"$f"
done
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.