Skip to content

Instantly share code, notes, and snippets.

@trantrongbinh
Created June 10, 2021 01:39
Show Gist options
  • Save trantrongbinh/88e75f8de5ac3cac28e184c8e5819e23 to your computer and use it in GitHub Desktop.
Save trantrongbinh/88e75f8de5ac3cac28e184c8e5819e23 to your computer and use it in GitHub Desktop.
Bash find file and move
#!/bin/bash

FORDER_M3U8="/data2/upload2/process/video/*"
FORDER_MP4="/data2/upload2/[email protected]/video"
FOLDER_MOVE="/backup/backup_m3u8/upload2_data2"
LOG="/backup/backup_m3u8/logs.txt"

for f in $FORDER_M3U8; do
    if test -f "$FORDER_MP4/raw-file-$(basename $f).mp4"; then
        mv $f $FOLDER_MOVE;
        echo "$f moved to $FOLDER_MOVE" >> $LOG;
    fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment