Or a Bash one liner navigate to the folder with the files and then run this in terminal:
for file in hortsu*;do echo "$file" "${file/_/-}";done;
Basically what this does is for files with the name 'hortsu' followed by any characters '*', echo the name of "$file" and also the name of file with all underscores replaced with dashes. When you feel comfortable with that just replace echo
with cp
to copy the files to the new name.
A pythonic solution.
Try this in a safe environement, maybe copy one or two files over to a new folder to test how it works.
Save the following code in gedit and give it a name with a file extension of '.py' something like rename_files_in_current_directory.py
:
# copy this code into gedit and save it to the directory with the files in it
import os
# for files in the current directory ('.')
for file_names in os.listdir('.'):
if '_' in file_names:
# using os.system use cp (copy) to copy file_names to file-names by replacing
# underscore with dash
os.system('cp '+file_names+' '+file_names.replace('_','-'))
Make sure python is installed. 'sudo apt-get install python'
Navigate to the folder in terminal with the script and the files and then run:
python the_name_given_to_the_python_script.py
Note:
You can delete the dashes in the above commands and scripts will remove the underscores.
for file in hortsu*;do cp "$file" "${file/_/}";done;
or in the python script change:
file_names.replace('_','-')
to file_names.replace('_','')