Thanks for looking at this Mathias.
The names are 'random' so it can be things like:
- 16591096719370948hik1082696166279904.txt
- ak9735409sdf4059hfsifhisajxilh.JPG
- lfgkfgkfkjkffkkkiiiiiiiyhhufyiffkkkyuasydq.png
The extension is unimportant as I don't specify that, just a long [a-z0-9] string.
In the case of
rename & move it fails at the
delete line also. The file is renamed (I used
Jungles name as folder script & a move command which did work perfectly up to now), but it doesn't move the file.
It displays a
cannot copy msg when reaching this line:-
MoveFile( $targetPath, $sourceFile, "NODIALOG");
See attached.
I assume it is related to the
delete op as that is where it halts &
move requires deletion, but as you can see this msg is showing 'copy'. Maybe the
options segment e.g. as NODIALOG is a common element?
Hopefully you will be able to see why...
Full script is
Log( 1, 10, "Renaming files to %%parent_folder_name%%[_N].*" );
@var $src_path = GetSourcePath();
@var $arr = PathGetParts( $src_path );
@var $name = $arr[0];
@var $prefix = StrReplace( PathGetPathPart( $src_path, 1 ), $name, "" );
@var $n = StrRFind( $prefix, "\\" );
if ( $n > 0 )
{
$prefix = StrSub( $prefix, $n + 1, StrLen( $prefix ) - $n - 1 );
@var $i;
@var $s;
@var $file;
@var $files;
$arr = GetSourceSelectedPaths();
for ( $i = 0; $i < arrayCount( $arr ); $i++ )
{
$file = $arr[$i];
$s = PathGetFileExtPart( $file );
$name = $prefix + "*" + $s;
$files = FindFiles( $src_path + $name );
$n = arrayCount( $files );
if ( $n == 0 )
{
$s = "";
}
else
{
if ( $n == 1 )
{
$s = $files[0];
RenameFile( $s, StrReplace( $name, "*", "_0" ), "RENAME_RO" );
}
$s = "_" + numtostr( $n );
}
RenameFile( $file, StrReplace( $name, "*", $s ), "RENAME_RO" );
}
}
else
{
Log( 1, 10, "It seems parent folder is root. Renaming impossible." );
}
// move
@var $arr1 = GetSourceSelectedPaths();
@var $items1 = arrayCount($arr1);
@var $MoveNameFullPath;
@var $targetPath;
@var $sourceFile;
@var $n1 = 0;
for( $n1 = 0; $n1 < $items1; $n1++ )
{
$MoveNameFullPath = $arr1[ $n1 ];
$targetPath = GetTargetPath();
$sourceFile = $MoveNameFullPath;
MoveFile( $targetPath, $sourceFile, "NODIALOG");
}