Rename file by removing url parameter in linux Rename file by removing url parameter in linux shell shell

Rename file by removing url parameter in linux


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.


for i in `ls *.zip?*`; do echo $i | cut -f 1 -d \? | xargs -n1 mv $i ; done

sorry to lazy to do checking for spaces in names right now. and unable to test. i don't have access to a bash based system at this moment in time.


If you have g++ >=4.9.2 then you can install rnm and do:

rnm -ns '/n/.zip' *.zip\?*# /n/ expands to file name without extension.

Or

rnm -rs '/\.zip\?.*/.zip/' *.zip\?*