Shell/bash Rename zip file ?

Discussion in 'PHP' started by thesurface, Sep 17, 2012.

  1. #1
    Okay so i have on my server in folder called /DL/ files like:

    543_1_2.zip?response-content-disposition=attachment&AWSAccessKeyId=361&Expires=2&Signature=336
    1_1_2.zip?response-content-disposition=attachment&AWSAccessKeyId=236&Expires=362&Signature=336

    how those files becomes with extension only as *.zip ? and not with those crap after ?response ...

    it should be recrusive as there are multiple files.
     
    thesurface, Sep 17, 2012 IP
  2. omgitsfletch

    omgitsfletch Well-Known Member

    Messages:
    1,222
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    145
    #2
    Can do this for you, with either a shell script, or a PHP script. Let me know which you prefer.
     
    omgitsfletch, Sep 18, 2012 IP
  3. samirj09

    samirj09 Well-Known Member

    Messages:
    335
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    125
    #3
    Not sure if you already did this, but this looks pretty straight forward.

    for i in `find .` ; do mv $i `echo $i | awk -F"?" '{print$1}'` ; done

    Run the above from the directory that these files are in. Should fix them all right up.
     
    samirj09, Sep 19, 2012 IP