Actually I have all my videofiles in a folder. I want to move each file to a individual subfolder named with the translated title
How can I do that?
Thanks
[REQ] Moving files to a new subfolder
You can try to make something based on what I made for that user:
viewtopic.php?t=4460
viewtopic.php?t=4460
Taking into account that I use field source for path, I have this:
But I have a issue: I have the films in a folder named films:
c:\videos\films\1.avi
c:\videos\films\2.mkv
...
this script is renaming this folder, so:
c:\videos\1\1.avi
and what I want is to create a subfolder where the video file is:
c:\videos\films\1\1.avi
What should I change in the script?
Thanks
Code: Select all
program NewScript;
var
source, newsource, root, folder, newfolder: string;
begin
source := GetField(fieldSource);
folder := ExtractFilePath(source);
root := ExtractFilePath(Copy(folder, 1, Length(folder) - 1));
newsource := folder + GetField(fieldTranslatedTitle) + ExtractFileExt(source);
if MoveFile(source, newsource) then
begin
SetField(fieldSource, newsource);
source := newsource;
newfolder := root + GetField(fieldTranslatedTitle) + '_' + GetField(fieldYear);
if MoveFile(Copy(folder, 1, Length(folder) - 1), newfolder) then
begin
newsource := newfolder + '\' + ExtractFileName(source);
SetField(fieldSource, newsource);
end;
end;
end.
c:\videos\films\1.avi
c:\videos\films\2.mkv
...
this script is renaming this folder, so:
c:\videos\1\1.avi
and what I want is to create a subfolder where the video file is:
c:\videos\films\1\1.avi
What should I change in the script?
Thanks
I stupidly only put functions for files and not for folders... so the script cannot create folders with a dedicated function for that
What could be done is a first pass to create all the folders using
Launch('cmd.exe', '/c md ' + folderName);
where foldername contains the full path (e.g. 'c:\videos\films\1')
Then a second pass to move the files into the folders.
Problem is that both cannot be done in 1 pass, as the script will not wait that the contains of "Launch" command has finished before processing the next line.
As alternative you could put a wait time (sleep) between the launch and the move.
What could be done is a first pass to create all the folders using
Launch('cmd.exe', '/c md ' + folderName);
where foldername contains the full path (e.g. 'c:\videos\films\1')
Then a second pass to move the files into the folders.
Problem is that both cannot be done in 1 pass, as the script will not wait that the contains of "Launch" command has finished before processing the next line.
As alternative you could put a wait time (sleep) between the launch and the move.
Sorry, it was easy
program NewScript;
var
source, newsource, root, folder, newfolder: string;
begin
source := GetField(fieldSource);
folder := ExtractFilePath(source);
root := ExtractFilePath(Copy(folder, 1, Length(folder) - 1));
newsource := folder + GetField(fieldTranslatedTitle) + ExtractFileExt(source);
if MoveFile(source, newsource) then
begin
SetField(fieldSource, newsource);
source := newsource;
newfolder := root + GetField(fieldTranslatedTitle) + ' (' + GetField(fieldYear) + ')';
if MoveFile(Copy(folder, 1, Length(folder) - 1), newfolder) then
begin
newsource := newfolder + '\' + ExtractFileName(source);
SetField(fieldSource, newsource);
end;
end;
end.