Script to move files within my server?

Discussion in 'Site & Server Administration' started by cpufreak3, Feb 5, 2008.

  1. #1
    I've got a huge list of files that are not being used anymore on my web server.

    I'd like to move them all to the root directory in a folder called not_used.

    Anyone know how to automate this process? I want to be able to provide the list in a text file and have it cut from the current location and paste to the new location. Thanks
     
    cpufreak3, Feb 5, 2008 IP
  2. redinlove

    redinlove Peon

    Messages:
    216
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    mv \directory \home\name\directory
     
    redinlove, Feb 5, 2008 IP
  3. boltok

    boltok Active Member

    Messages:
    257
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    78
    #3
    @ redinlove, directory names don't need to be escaped. It just causes confusion and could potentially break the system.

    cpufreak3, you could setup a cronjob that does this. It should be as simple as a one-line command like this:

    for files in `cat /path/to/text_file.txt`;do mv $files /not_used/;done
    Code (markup):
     
    boltok, Feb 6, 2008 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #4
    Might help if we knew the Operating System you're using.
     
    joebert, Feb 6, 2008 IP
  5. cpufreak3

    cpufreak3 Well-Known Member

    Messages:
    346
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #5
    Well, I don't have direct access to the server... It is owned by a University so all I've got is FTP access.

    I'm not too sure what cron but I assume I can't use it. I was hoping to use some type of PHP script.
     
    cpufreak3, Feb 6, 2008 IP