Page 1 of 2
Please help I need a Script !
Posted: 08 Apr 2009 12:33
by Ysl
Hi
I know almost anything in programming so I hope I will find some help !
I would like copy the name of an .mp3 file, delete it, and create a .txt file with the name of the mp3 file.
So pushing a key will transform "michael jackson - billie jean.mp3" to "michael jackson - billie jean.txt" (with a file size of 0 K)
Thanks for your help !
Ysl
Re: Please help I need a Script !
Posted: 08 Apr 2009 13:50
by TheQwerty
Give this a try:
Code: Select all
End(GetInfo("CountSelected") < 1, "No item(s) selected.");
Global($files);
$files = Report("{Dir |{FullName};{Ext}<crlf>|}", 1);
Setting("AllowRecursion", 1);
Sub("_newTXT");
RegexReplace($files, $files, "^(.*);.*<crlf>", "$1|");
Delete(1,1,$files);
"_newTXT"
Global($files, $i);
$i = $i Like "" ? 1 : $i;
$token = GetToken($files, $i, "<crlf>");
End($token Like "",, 1);
$file = GetToken($token, 1, ";");
$ext = GetToken($token, 2, ";");
RegexReplace($newFile, $file, "$ext$", "txt");
New($newFile);
$i = $i + 1;
Sub("_newTXT");
Re: Please help I need a Script !
Posted: 08 Apr 2009 15:07
by Ysl
THANKS ! so good so fast !
It works almost perfectly !
I have this error message :
And I have to press continue for each file...
Thanks again !
Ysl
Re: Please help I need a Script !
Posted: 08 Apr 2009 15:58
by j_c_hallgren
Ysl wrote:THANKS ! so good so fast !
Yes, TheQwerty is one of great scripters and very helpful as well!
I have this error message :
See our wiki for this one:
http://88.191.26.34/XYwiki/index.php/IN ... hecker_Off
As it notes, one can do same via Setting.
Re: Please help I need a Script !
Posted: 08 Apr 2009 16:46
by Ysl
Perfect !
Thanks guys for your help and thanks XYplorer for scripting !
Ysl
Re: Please help I need a Script !
Posted: 08 Apr 2009 17:49
by TheQwerty
Ysl wrote:It works almost perfectly !
I have this error message :
Doh.. Yep, I indeed forgot to disable the recursion checker in the script. Luckily, j_c_hallgren's always quick with finding the relevant parts of the wiki or forum posts.
In any case, I've updated the script above to temporarily disable the recursion checker.
Glad that works for you!
Re: Please help I need a Script !
Posted: 08 Apr 2009 18:59
by Ysl
One last thing, I don"t know if it is possible but it would save time
Can we pass the delete confirmation panel and delete without asking ?
Thanks
Ysl
Re: Please help I need a Script !
Posted: 08 Apr 2009 19:11
by TheQwerty
Ysl wrote:Can we pass the delete confirmation panel and delete without asking ?
Take a look here:
http://88.191.26.34/XYwiki/index.php/Sc ... nd:_delete
Then you can change the Delete command to work however you'd like.
You'll probably want "Delete(1,0,$files);"
Re: Please help I need a Script !
Posted: 08 Apr 2009 22:30
by Ysl
It's even better now !
Merci encore !
Ysl
Re: Please help I need a Script !
Posted: 13 Apr 2009 20:58
by Ysl
May I ask one more refinement ?
I would like to select all the files in a folder (.jpg, mp3, txt) and when I run the script, I would like for only the mp3 to be renamed/deleted.
There should be a "if -then" command somewhere which can do that I hope...
Thanks
Re: Please help I need a Script !
Posted: 16 Apr 2009 22:30
by TheQwerty
Ysl wrote:I would like to select all the files in a folder (.jpg, mp3, txt) and when I run the script, I would like for only the mp3 to be renamed/deleted.
It would probably be smarter to use a selection or visual filter, but I've updated the above code and it should ignore anything that doesn't have the extension mp3.
Ysl wrote:There should be a "if -then" command somewhere which can do that I hope...
Unfortunately, XY scripting does not yet have real if-else constructs, so it's not that easy. As I wanted to keep the Delete as a single bulk call it won't be that easy even when he gives them to us.
Re: Please help I need a Script !
Posted: 16 Apr 2009 22:40
by Ysl
Well, Thanks again for your help but unfortunately, the script work as before, the "folder.jpg" was renamed "folder.txt" and deleted...
Ysl
Re: Please help I need a Script !
Posted: 16 Apr 2009 22:51
by TheQwerty
Yeah.. that's not going to work.
Can't you just use a Selection or Visual filter so you're only dealing with MP3s in the first place?
Re: Please help I need a Script !
Posted: 17 Apr 2009 09:26
by Ysl
I don't really understand those options but will look in the manual !
Re: Please help I need a Script !
Posted: 07 Nov 2009 10:02
by Ysl
Hi
It seem that since 8.50 or 8.60, this script doesn't work anymore !
When running it, all that happen is a new file in the same folder
Name of the new file (which should be the same as the selected one but with the .txt extension) : $newFile
Thanks for your help !
Ysl