I want to rename files by removing the last N characters
For example I want to rename these files by removing the last 7 characters
From:
file.txt.123456
To:
file.txt
Is this doable in a single command?
Batch Rename with File Explorer Head to the folder containing the files you wish to rename. Order the files how you wish to rename them. Press CTRL + A to select all the files in the folder, then right-click and select Rename. Input your new file name, and press Enter.
The $ s/. $// function call executes on the endmost line of the file. It replaces the last character (s) with an empty string. In this way, it completely takes off the last character of the file.
To rename multiple files from File Explorer, select all the files you wish to rename, then press the F2 key. The name of the last file will become highlighted. Type the new name you wish to give to every file, then press Enter.
Are you using bash?
file="file.txt.123456"
mv $file ${file::(-7)}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With