Re: The archive of the snapshot is crazy
Posted: Fri Nov 04, 2016 11:32 am
Hi everyone,
I had the same issue with my IPM-721 camera. All of those ftp'd jpg pictures are buried under tons of directories. I'm posting up the code I came up with, in case it fits anyone's needs better than the other awesome solutions already suggested here. This is a single windows batch file that you run in the root ftp landing zone where the AMC* directory is created by the camera when it does it's FTP. It takes the path the camera creates, and uses parts of it, like the date and time, to make a rename command to create a new filename for the JPG file. Then, like the other examples here, it flattens the directory structure created by the camera, moving all the JPG pictures to the root ftp directory. I named it "#MOVEFLAT.BAT" but you can call it anything you want.
If you want to test this without changing anything, put it in the ftp landing zone base directory and remove everything after and including the "start /w" command. Then you can inspect the #rename.bat file and make sure its going to rename the files you want, the way you want, before actually changing anything.
Hope this helps!
Zistrosk
I had the same issue with my IPM-721 camera. All of those ftp'd jpg pictures are buried under tons of directories. I'm posting up the code I came up with, in case it fits anyone's needs better than the other awesome solutions already suggested here. This is a single windows batch file that you run in the root ftp landing zone where the AMC* directory is created by the camera when it does it's FTP. It takes the path the camera creates, and uses parts of it, like the date and time, to make a rename command to create a new filename for the JPG file. Then, like the other examples here, it flattens the directory structure created by the camera, moving all the JPG pictures to the root ftp directory. I named it "#MOVEFLAT.BAT" but you can call it anything you want.
Code: Select all
@echo off &setlocal
rem For dealing with ftp named files/directories from an AMCREST IPM-721 camera
rem First rename all the files so they include the subdirectory path in the filename
rem Example:
rem rename F:\BACKUPS\kahtrynnyawcam\AMC001YX_48Y180\2016-11-04\001\jpg\10\28\46[M][0@0][0].jpg AMC001YX_48Y180-2016-11-04-001-10-28-46M.jpg
rem set environment
set "basedrive=F:"
set "basedir=F:\BACKUPS\kahtrynnyawcam\"
set "search=\"
set "search1=F:\BACKUPS\kahtrynnyawcam\"
set "search2=[M][0@0][0]"
set "search3=-jpg-"
set "replace=-"
set "replace1="
set "replace2=M"
set "textfile=#rename.bat"
set "newfile=#rename1.bat"
rem switch to base drive (i.e. F:)
%basedrive%
rem switch to base directory where ftp files are uploaded (i.e. F:\BACKUPS\kahtrynnyawcam)
cd %basedir%
rem list all JPG filenames and their full paths into #rename.bat
dir /s/b *.jpg > #rename.bat
rem loop through doing find and replaces and form the rename commands
(for /f "delims=" %%i in (%textfile%) do (
set "line=%%i"
set "line1=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search1%=%replace1%!"
set "line=!line:%search2%=%replace2%!"
set "line=!line:%search%=%replace%!"
set "line=!line:%search3%=%replace%!"
echo(rename !line1! !line!
endlocal
))>"%newfile%"
echo exit >> %newfile%
del %textfile%
rename %newfile% %textfile%
rem execute the rename batch script just created so filenames get their path info in them
start /w #rename.bat
del #rename.bat
rem Move all files in subfolders to this folder, and with their new names they'll sort nicely
for /r %basedir% %%i in (*) do @move "%%i" "%basedir%"
rem Delete all empty subfolders (ones with new files wont be empty so wont be deleted)
for /d %%i in (%basedir%*) do @rmdir /s /q "%%i"
exit
Hope this helps!
Zistrosk