Created
April 27, 2017 06:10
-
-
Save marhan/85bc6956d5207de8b3061c783258c9f9 to your computer and use it in GitHub Desktop.
Copies the CSV files recursive to another location and garanties file name uniqueness by random filename.
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 | |
DESTINATION_PATH="/PATH_TO_DESTINATION" | |
for SOURCE_FILE in `find "/PATH_SOURCE" -name *.csv`; do | |
FILE_NAME=$(basename "$SOURCE_FILE") | |
FILE_NAME_EXTENSION="${FILE_NAME##*.}" | |
FILE_NAME_PART="${FILE_NAME%.*}" | |
DESTINATION_FILE_NAME="${FILE_NAME_PART}-${RANDOM}.${FILE_NAME_EXTENSION}" | |
CMD="cp $SOURCE_FILE $DESTINATION_PATH/$DESTINATION_FILE_NAME" | |
eval $CMD | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment