[ILUGC] Re: [Help] Looking simple solution for renaming multiple files in shell
- From: Jackson Isaac <jacksonisaac2008@xxxxxxxxx>
- To: ilugc@xxxxxxxxxxxxx
- Date: Sun, 5 Aug 2018 18:25:57 +0530
On Sun, Aug 5, 2018 at 5:08 PM, Baskar Selvaraj <baskar@xxxxxxxxxxxx> wrote:
I am looking for a simple solution for renaming multiple files in shell.
Previously i was using Thunar file manager for doing this. Now I am
looking for a command line solution.
Mod-01 Lec-22(A) One-dimensional compressible flows, isentropic flows-
Expected output filename:
I require only the last 11 characters in the filename, removing all other
I usually write a python script for such tasks.
You can make use of built-in `os` package to list all the files in the
Traverse through each file name, do string manipulation on the
filename and get the new filename
that you want to rename with. For e.g., new_name = filename[-11:]
Then use `os.rename(filename, new_name)`
You might need to use os.path to get the absolute path to file. But
the above should give a idea
to write a script.
Hope it helps :)
Alumnus of Amrita Vishwa Vidyapeetham & TU München
ILUGC List: http://www.freelists.org/list/ilugc
ILUGC Web: http://ilugc.in/
Other related posts: