Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename file by removing url parameter in linux

I downloaded some files using wget and the files are in the following format:

test.zip?AWSAccesskeyId=XXXXXXX&Expires=00000000&Signature=ZZZZZZZZZZ

Is there any way, to rename those files properly by removing the URL parameters. Also is there any way, to download such files, with proper name(without URL parameter) from wget.

I tried with mmv with the following command:

mmv "*.zip*" "#1.zip"

But I can't find any way to install mmv. I am using CentOS 6. So, please suggest any way, other than this.

like image 786
biztiger Avatar asked Jan 02 '13 21:01

biztiger


Video Answer


1 Answers

for file in *.zip\?*; do mv "$file" "${file%%\?*}"; done

As far as I can tell, there's no option to wget telling it not to include the query string in the local filename. You can use the -O option to specify an explicit filename, and fix the driver script to remove the query string itself.

like image 90
Barmar Avatar answered Sep 22 '22 16:09

Barmar