简体   繁体   中英

Renaming multiple zip files with complex name using single command in linux

I have multiple zip files in a folder with names like below:

"abc.zip-20181002084936558425"

How to rename all of them with one command to get result like below:

"abc-20181002084936558425.zip"

I want the timestamp before the extension for multiple filenames. Now every file has different timestamp so renaming should consider that. Can I rename multiple files like this using single command.

Providing your file are really all with the same name convention and you being in the right directory :

for i in *.zip-*; do newName=${i//.zip};mv $i $newName".zip";done

should do the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM