|
|
For LINUX ONLY (and for git but can easily be adapted)
|
|
|
|
|
|
See the file [run_rename.sh](https://git.immc.ucl.ac.be/robotran/robotran_awesome_examples/blob/master/run_rename.sh)
|
|
|
|
|
|
```
|
|
|
#
|
|
|
# @author S. Timmermans
|
|
|
# @Date january 2020
|
|
|
#
|
|
|
# file .sh that rename the file name and string inside the files
|
|
|
#
|
|
|
# simply choose the string to be replaced and launch ./run_rename.sh in command line
|
|
|
# place the .sh file outside the folder (and subfolders) that you want to modify
|
|
|
# you have to choose the path of the folder to modify
|
|
|
#
|
|
|
#
|
|
|
# step 1: put the run_rename.sh just outside the robotran project
|
|
|
# step 2: modify the run_rename file : type_path, old_name, new_name
|
|
|
# step 3: run the run_rename.sh in command line ( "./run_rename.sh" if it is put as a executable file).
|
|
|
#
|
|
|
# BE ADVISED:
|
|
|
# the .sh modifies files names and content !
|
|
|
#
|
|
|
# FOR UNIX ONLY
|
|
|
# FOR GIT PROJECT ONLY
|
|
|
#
|
|
|
# if you want to use for a non-git project, just suppress the "git" commands
|
|
|
#
|
|
|
|
|
|
#---------------------------------------------------------
|
|
|
#---------------------------------------------------------
|
|
|
# put here the name of the folder containing the project
|
|
|
#
|
|
|
# replace good_name with your input string
|
|
|
# replace suffix and type path with your langage
|
|
|
old_name="External_Force"
|
|
|
new_name="pendulum_spring_python" #$old_name"_matlab"
|
|
|
type_path="Python/"
|
|
|
path_typo=$type_path"temporaXR/"
|
|
|
|
|
|
|
|
|
# some paths
|
|
|
path_init=$type_path$old_name"/"
|
|
|
path_final=$type_path$new_name"/"
|
|
|
|
|
|
# move the folder name to temporary one
|
|
|
git mv $path_init $path_typo
|
|
|
|
|
|
# some print
|
|
|
echo $path_init
|
|
|
echo $new_name
|
|
|
|
|
|
# rename filenames
|
|
|
find $path_typo -type f -name "*"$old_name"*" | while read FILE ; do
|
|
|
git mv "${FILE}" "${FILE//$old_name/$new_name}" ;
|
|
|
done
|
|
|
|
|
|
# remplace string inside files
|
|
|
find $path_typo -type f -exec sed -i "s/"$old_name"/"$new_name"/g" {} \;
|
|
|
|
|
|
# go to final folder name
|
|
|
git mv $path_typo $path_final
|
|
|
|
|
|
``` |
|
|
\ No newline at end of file |