Last active
February 8, 2021 13:37
-
-
Save jopfre/e69c75390791c1da82ad05466665dfba to your computer and use it in GitHub Desktop.
This file contains 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
for file in ./*.png; | |
do | |
if grep -q ${file:2} ./fileslist.txt; | |
then | |
echo "skipping $file" | |
else | |
echo "moving $file" | |
mv "$f" ./newdir | |
fi | |
done |
This file contains 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
while IFS="" read -r file || [ -n "$file" ] | |
do | |
printf '%s\n' "$file" | |
mv ./$file ./newdir/ | |
done < fileslist.txt |
This file contains 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
# get list of files in current dir | |
printf '%s\n' *.png > current_dir_files.txt | |
# sort current dir files and files to exclude | |
sort current_dir_files.txt | |
sort filenames.txt | |
# save the filenames which exist in the current dir but not in the exclude list | |
comm -23 current_dir_files.txt filenames.txt > required_files.txt | |
# make newdir if it doesnt exist | |
mkdir -p ./newdir/ | |
#loop through required files and move to newdir | |
while IFS="" read -r file || [ -n "$file" ] | |
do | |
printf '%s\n' "$file" | |
mv ./$file ./newdir/ | |
done < required_files.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment