I need to rename files names like this
transform.php?dappName=Test&transformer=YAML&v_id=XXXXX
to just this
XXXXX.txt
How can I do it?
I understand that i need more than one mv
command because they are at least 25000 files.
I need to rename files names like this
transform.php?dappName=Test&transformer=YAML&v_id=XXXXX
to just this
XXXXX.txt
How can I do it?
I understand that i need more than one mv
command because they are at least 25000 files.
Ok, you need to be able to run a windows binary for this.
But if you can run Total Commander, do this:
Select all files with *, and hit ctrl-M
In the Search field, paste "transform.php?dappName=Test&transformer=YAML&v_id="
(Leave Replace empty)
Press Start
It doesn't get much simpler than that. You can also rename using regular expressions via this dialog, and you see a realtime preview of how your files are going to be renamed.
If you are using zsh you can also do this:
You may use whatever you want to transform the name (perl, sed, awk, etc.). I'll use a python one-liner:
Here's the same script entirely in Python:
Side note: you would have had an easier life saving the pages with the right name while grabbing them...
I'd use ren-regexp, which is a Perl script that lets you mass-rename files very easily.
You write a fairly simple shell script in which the trickiest part is munging the name.
The outline of the script is easy (bash syntax here):
Modifying the name has many options. I think the easiest is probably an awk one-liner like
so...
update
Okay, as pointed out below, this won't necessarily work for a large enough list of files; the * will overrun the command line length limit. So, then you use:
Easiest solution is to use "mmv"
You can write:
Where the "#1" is replaced by whatever is matched by the first wildcard. Similarly #2 is replaced by the second, etc.
So you do something like
To rename index1_type9.txt to t9_i1.txt
mmv is not standard in many Linux distributions but is easily found on the net.