Eu uso o software iSpy para gravar áudio e configurei-o para salvar as gravações em uma pasta. O problema é que não há nenhuma organização, então eu tenho milhares de gravações de áudio em uma pasta.
Meu objetivo seria configurar uma estrutura de pastas que organizasse por data e movesse todos os arquivos que foram criados / modificados (observação: a data de criação não é igual à data de modificação, portanto, se houver diferença no script , Eu gostaria de ambos disponíveis por favor.) No final do dia.
A localização da pasta é: M: \ Software de Segurança \ iSpy \ audio \ VHCEX
Este é um nome de arquivo de exemplo: 1_2016-04-19_14-06-02.mp3
ou 1_ AAAA-MM-DD_HH-MM-SS.mp3
Em minha pesquisa, deparei com os seguintes scripts [source]
@echo off
for /d %%i in (*) do (
cd %%i
call :doMove
cd ..
)
echo Really Done
goto eof:
pause
:doMove
echo Moving files... Please wait...
for /F "tokens=1-3,4* delims=-_" %%a in ('dir /b *.avi') do (
title Processing %%b-%%c-%%d_%%e
if not exist ".\%%b\%%c\%%d" (
mkdir ".\%%b\%%c\%%d"
echo New Date: \%%b\%%c\%%d
)
if exist "%%a_%%b-%%c-%%d_%%e" move "%%a_%%b-%%c-%%d_%%e" ".\%%b\%%c\%%d\%%e"
if exist "%%a_%%b_%%c-%%d-%%e" move "%%a_%%b_%%c-%%d-%%e" ".\%%b\%%c\%%d\%%e"
)
for /F "tokens=1-3,4* delims=-_" %%a in ('dir /b *.mp4') do (
title Processing %%b-%%c-%%d_%%e
if not exist ".\%%b\%%c\%%d" mkdir ".\%%b\%%c\%%d"
if exist "%%a_%%b-%%c-%%d_%%e" move "%%a_%%b-%%c-%%d_%%e" ".\%%b\%%c\%%d\%%e"
if exist "%%a_%%b_%%c-%%d-%%e" move "%%a_%%b_%%c-%%d-%%e" ".\%%b\%%c\%%d\%%e"
)
echo Moving Thumbs
for /F "tokens=1-3,4* delims=-_" %%a in ('dir /b thumbs\*.jpg') do (
title Processing %%b-%%c-%%d_%%e
if exist "thumbs\%%a_%%b-%%c-%%d_%%e" move "thumbs\%%a_%%b-%%c-%%d_%%e" ".\%%b\%%c\%%d\%%e"
if exist "thumbs\%%a_%%b_%%c-%%d-%%e" move "thumbs\%%a_%%b_%%c-%%d-%%e" ".\%%b\%%c\%%d\%%e"
)
title Done.
:EOF
Também encontrei um script em Perl [source]
#!/usr/bin/perl -w
use strict;
use File::stat;
use File::Copy;
use POSIX;
use Mail::Sendmail;
use Date::Calc qw(:all);
my $oldest_week = 4;
my $delete_week = 1;
my $move_count = 0;
my $delete_count = 0;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$year += 1900;
$mon += 1;
my ($current_week,$current_year) = Week_of_Year($year, $mon, $mday);
my @folders = ("D:/iSpy/video/Front Door",
"D:/iSpy/video/Front Path",
"D:/iSpy/video/Garden",
"D:/iSpy/video/Lounge",
"D:/iSpy/video/Patio",
"D:/iSpy/video/Shed");
foreach (@folders)
{
my $viddir=$_;
print "$viddir\n\n";
opendir("curdir",$viddir)||die("Cannot open Directory!");
my @names=readdir("curdir");
foreach (@names)
{
my $name=$_;
my $source = $viddir."/".$name;
my $upname=uc($name);
my $pos_avi=index($upname,".AVI");
my $pos_mp4=index($upname,".MP4");
if ($pos_avi > 0 or $pos_mp4 > 0)
{
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime (stat($source)->mtime);
$year += 1900;
$mon += 1;
my ($week,$year) = Week_of_Year($year, $mon, $mday);
print "file $source was updated on $year $mon $mday - that was week $week - ";
my $target="$viddir/$week";
print "Move to folder $viddir/$week\n";
move($source,$target);
$move_count ++;
}
}
}
if ($oldest_week >= $current_week) {
$delete_week = 52 + $current_week - $oldest_week;
} else {
$delete_week = $current_week - $oldest_week;
}
@folders = ("D:/iSpy/video/Front Door/$delete_week",
"D:/iSpy/video/Front Path/$delete_week",
"D:/iSpy/video/Garden/$delete_week",
"D:/iSpy/video/Lounge/$delete_week",
"D:/iSpy/video/Patio/$delete_week",
"D:/iSpy/video/Shed/$delete_week");
foreach (@folders)
{
my $delete_dir=$_;
opendir("curdir",$delete_dir)||die("Cannot open Directory!");
my @names=readdir("curdir");
foreach (@names) {
my $name=$_;
my $target = "$delete_dir/$name";
my $upname=uc($name);
my $pos_avi=index($upname,".AVI");
my $pos_mp4=index($upname,".MP4");
if ($pos_avi > 0 or $pos_mp4 > 0)
{
print "file to delete is $target\n";
unlink $target;
$delete_count ++;
}
}
}
my $mail_body = "$move_count moved";
if ($delete_count > 0) {
$mail_body = $mail_body . ", $delete_count deleted from folder $delete_week\n";
}
print "$mail_body\n";
my %mail = (
To => '[email protected]',
From => '[email protected]',
Subject => 'Daily iSpy Recordings Move / Delete',
Message => $mail_body,
'content-type' => 'text/html; charset="iso-8859-1"',
'X-Mailer' => "Mail::Sendmail version $Mail::Sendmail::VERSION",
);
$mail{Smtp} = 'smtp.anywhere.com';
if (sendmail %mail) { print "Mail sent OK.\n\n" }
else { print "Error sending mail: $Mail::Sendmail::error \n" }
Ambos precisam ser ajustados para atender ao meu caso específico, mas não sei como editar um deles.