You are not logged in.
Hi all!
I would like to move a file in one folder with specific extension to a subfolder in the same folder.
Basically I have a folder called 'Hero', in this folder I have a file called 'Hero.srt' and 'Hero.avi', and I would like to create under folder 'Hero' an subfolder called 'Subtitles' and move the 'Hero.srt' into it.
So I have:
Hero
Hero.avi
Hero.srt
And I would like to get:
Hero
Hero.avi
Subtitles
Hero.srt
I'm not a programmer, but I'l try to put things together and I was able to put this code together, but there is some kind of problem with it on the second line (reported by ReNamer).
var
FileName:WideString;
begin
FileName := WideExtractFileExt(FileName);
if (FileName = '.srt') then
begin
FileName := 'Subtitles\' + FileName;
end;
end.
If anybody is willing to fix the code for me I would be really happy.
Any reaction is much appreciated!
Thank you!
Jan
Last edited by alcestneige (2013-01-20 16:24)
Offline
As i wrote in the other thread; ReNamer's PascalScript has two build-in vars: FileName and FilePath.
So you can't reuse this strings for your own vars.
Use this script on two or three files to see what they hold:
begin
// Add your code here
ShowMessage(FileName);
ShowMessage(FilePath);
end.
- - -
Jan wrote> "FileName := 'Subtitles\' + FileName;"
I don't know (not tested) if this relative path will work.
If not, remember my hint about how to extract 'Parent' folder.
- - -
Jan wrote> "but there is some kind of problem with it on the second line (reported by ReNamer)."
You can press Ctrl+C on that error dialog to paste the error message here, so we get an glue what you have seen.
.
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
As Stefan has suggested, FileName is a reserved variable name which is used internally by ReNamer. The error has occurred because you tried to redeclare that reserved variable.
Your attempt was very close, good work for a non-programmer. So here is a slightly adjusted code which should do what you wanted:
var
Extension: WideString;
begin
Extension := WideExtractFileExt(FileName);
if (Extension = '.srt') then
begin
FileName := 'Subtitles\' + FileName;
end;
end.
Offline
Thank you Stefan and den4b, it works wonderful!
Offline