I accidently renamed all of my files by adding a prefix multiple times to each directory. I have tried the "rename" command and some peal scripting but I still can’t resolve name changes. Any ideas on how to remove all the dates at once so that I just have directory?
Example
mv 2020-11-30-2020-11-30…2020-11-30-Documents Documents/
3
Answers
These commands both worked:
Assuming your filenames don’t contain linebreak, quotes. or other special chars:
You can check the output produced by the above command, if it looks good, pipe the output to
|sh
NOTE: the backslash before
ls
is for ignoring your alias if you had ls alias.Here is a solution which does not require the use of
regex
. Based onvimv
and the multi-cursor edition inVscode
:Both packages are shipped in most Linux distributions:
Open a terminal and setup codium as your editor:
export EDITOR="codium -w"
Browse the terminal in the appropriate folder and type
vimv
. Hit enterVscodium opens, and shows the list of files and folders
Add cursors where you want. Quoting from the doc:
Delete whatever you want, save the file, and exit
The files and folders should be renamed accordingly
Checkout the website of vimv for more informations and screencasts