I have been backing up files from a CCTV camera to an FTP directory without really thinking about it for about 6 months, and inadvertently created a directory with what might be 100,000 files in it.

This week I've decided to do something about it, as now whenever I run the backup script it stalls for 30 minutes while it downloads the filelist needed for the mirror operation.

My first action was to create a small script to use ls to echo all of the filenames in that directory to a file. I then ran that file through google sheets to extract sub-portions of the file name from which to create more managable sub-folders. When I then made the test script below to move the first file I get mv: Access failed: 501 File not found (ARC20170315113818.mp4):


# @description: attempt to move file to new folder

#FTP login details

lftp -u "$USER","$PASSWORD" $HOST << EOF

cd /CCTVArchive/V2/

mv ARC20170314180647.mp4 2017/03/14/



Is there a reason why ls and mv would have a different opinion on what files exist?



The error message related to the target directory for the move not existing! Once I've prefaced the mv commands with the appropriate number of mkdir commands they all work as expected.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.