Created
August 26, 2016 13:17
-
-
Save Sam-R/4146d2da1acd4bf8bff381f3fc073505 to your computer and use it in GitHub Desktop.
Bash script to find files from one directory, rename them with a PNG extension and move them to another directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Move a Source set of files to a Destination folder with a ".png" extension. | |
# Note that by default this script looks for any file with a name ending in "_IMAGE" but you can change this as you see fit. | |
# It also limits the depth to 1, so it doesn't search subfolders. | |
# The original purpose of this script was to move artwork loaded into an SFTP area by a client and place it somewhere else for automated processing, keeping their SFTP jail clear from old files. | |
# One Liner for Crontab | |
#cd /path/to/source; find . -name '*_IMAGE' -maxdepth 1 -exec mv '{}' /path/to/destination/'{}'.png \; ; | |
# We move to the source directory of the files, so during the find there's less work to to extracting the file name from the path in the mv command. | |
cd /path/to/source | |
# We're specifically looking for "_IMAGE" files in this directory only and moving them to a destination with an extension. | |
find . -name '*_IMAGE' -maxdepth 1 -exec mv '{}' /path/to/destination/'{}'.png \; ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment