Skip to content

Instantly share code, notes, and snippets.

@oktavianidewi
Last active July 1, 2018 02:32
Show Gist options
  • Select an option

  • Save oktavianidewi/8ad8fd56606a2c56ea093ca3d252c8d2 to your computer and use it in GitHub Desktop.

Select an option

Save oktavianidewi/8ad8fd56606a2c56ea093ca3d252c8d2 to your computer and use it in GitHub Desktop.
rename batch files with bash script

to rename batch files with bash script in mac terminal, type this command:

for f in *.jpg
do 
    mv "$f" "${f/*. /}"
done

in a bash file named rename-files.sh put the file in a folder where the files are going to be rename. run the bash file by : sh rename-files.sh

code description: mv command means move, mv "old_name" "new_name" it actually move a file with an "old-name" to a new file named "new_name".

$f matches to *.jpg to move the renamed files to a folder, these steps must be followed: create the destination folder, then add the destination name following the "new_name".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment