bulk naming of files after folders?

Discussion in 'Mac Basics and Help' started by urbanforces, Jun 4, 2019.

  1. urbanforces macrumors newbie

    urbanforces

    Joined:
    Jun 11, 2013
    Location:
    hong kong
    #1
    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
     
  2. 960design macrumors 68030

    Joined:
    Apr 17, 2012
    Location:
    Destin, FL
    #2
    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.
     
  3. urbanforces thread starter macrumors newbie

    urbanforces

    Joined:
    Jun 11, 2013
    Location:
    hong kong
    #3
    ok will do. in the meantime, i downloaded better file rename and it has an option for "paths?". thanks
     
  4. ChrisA, Jun 4, 2019
    Last edited: Jun 4, 2019

    ChrisA macrumors G4

    Joined:
    Jan 5, 2006
    Location:
    Redondo Beach, California
    #4
    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.
     
  5. NoBoMac, Jun 4, 2019
    Last edited: Jun 5, 2019

    NoBoMac macrumors 68020

    Joined:
    Jul 1, 2014
    #5
    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
    
     
  6. urbanforces thread starter macrumors newbie

    urbanforces

    Joined:
    Jun 11, 2013
    Location:
    hong kong
    #6
    thanks for the replies but i think those terminal actions are beyond my programming threshold
     

Share This Page

5 June 4, 2019