I'm trying to get a script that will rename and move videos. Here is what I have:
#!/bin/bash
src="/mnt/Files_Apps/temp/"
dest="/mnt/Files_Apps/TFTP root/"
for file in "$src"*.*; do
newfile="${dest}$(date -r "$file" +"%Y-%m-%d %H %M %S").MOV"
mv "$file" "$newfile"
done
When I debug the output, I see this:
$ sudo bash -v videorename.sh
date -r "$file" +"%Y-%m-%d %H %M %S"
mv: '/mnt/Files_Apps/temp/IMG_7662.MOV' and '/mnt/Files_Apps/TFTP root/2016- 05-08 11 57 58.MOV' are the same file
date -r "$file" +"%Y-%m-%d %H %M %S"
mv: '/mnt/Files_Apps/temp/IMG_7687.MOV' and '/mnt/Files_Apps/TFTP root/2016- 05-09 16 03 39.MOV' are the same file
date -r "$file" +"%Y-%m-%d %H %M %S"
date -r "$file" +"%Y-%m-%d %H %M %S"
date -r "$file" +"%Y-%m-%d %H %M %S"
date -r "$file" +"%Y-%m-%d %H %M %S"
Details of the src directory:
ls -lia
total 148402
1443129 drwxrwxrwx 3 chris linuxadmin 0 Oct 9 18:12 .
26870564 drwxrwxrwx 15 chris linuxadmin 0 Oct 5 15:51 ..
1441900 -rwxrwxrwx 1 chris linuxadmin 75031725 May 8 11:57 IMG_7662.MOV
1443124 -rwxrwxrwx 1 chris linuxadmin 76930641 May 9 16:03 IMG_7687.MOV
I've changed the contents of the source directory several times. Some files it chokes on, others work fine. I can't figure out why it's seeing certain files (all in MOV format imported form my iphone) as duplicates, especially since I'm moving files to a new directory. Any help would be greatly appreciated.
*.*
is Windows, on Linux just use*
. – Byte Commander♦ Oct 10 '16 at 18:09newfile="${dest}...
. – Byte Commander♦ Oct 10 '16 at 18:12