Please help I need a Script !

Discuss and share scripts and script files...
jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Please help I need a Script !

Post by jacky »

Yes, I believe there was a syntax change, so regexreplace (among others) does now work as a function when () are used. So you need to replace a line such as this

Code: Select all

RegexReplace($files, $files, "^(.*);.*<crlf>", "$1|");
with e.g. this

Code: Select all

$files = RegexReplace($files, "^(.*);.*<crlf>", "$1|");
This should work:

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";
	$files = RegexReplace($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, ";");
	$newFile = RegexReplace($file, "$ext$", "txt");
	New $newFile;
	$i = $i + 1;
	Sub "_newTXT";
Proud XYplorer Fanatic

Ysl
Posts: 158
Joined: 03 Jan 2007 22:22

Re: Please help I need a Script !

Post by Ysl »

Thanks !

It almost work...

I get this error message Image

when the xxx.txt is already created but the xxx.mp3 is not yet deleted

File name lenght is "normal"

Ysl

Ysl
Posts: 158
Joined: 03 Jan 2007 22:22

Re: Please help I need a Script !

Post by Ysl »

Ok, don't know why but now it works !

Thanks again !!

Ysl

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Please help I need a Script !

Post by SkyFrontier »

I needed this to substitute *any* files for zero sized one.
That did the trick:

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";
   $files = RegexReplace($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, ";");
   $newFile = RegexReplace($file, "$ext$", "$ext");
   New $newFile;
   $i = $i + 1;
   Sub "_newTXT";
Assigned SHIFT+1 to it under "User/Manage Commands/Run Script".
Problem: it renamed all zeroed files as "*file*-01.*ext*", due to collision name.

So I applied the following as SHIFT+2:

Code: Select all

#250; rename s, -01/
It does not affect folders or subfolders in a bad manner, just files - so I assume it's safe to use "#250-select all".

-Can I have a little help to have the same effect in a single stroke, by means of the script detecting files only by checking size of files, for instance, or another XY-way? I mean: the script could avoid name collision, plus more safely handling *files* only with value >0 (auto-selection of *all files only*), all in a single script?
-Can those resulting empty files have same attributes as their original counterparts?

Thank you!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Please help I need a Script !

Post by SkyFrontier »

This will:
-select *ALL* files only (not subfolders!) on a folder;
-*delete them all* without a prompt (unable to provide, people - sorry!);
-substitute all deleted files with zero-sized .txt files, replicating original file names plus extensions.
This is the hardest but closest way I got to accomplish my Catalog Maker. Lacking system dates replication and auto-subfolders scan, is pretty useless as a Catalog Maker.
Feel free to contribute...

Code: Select all

   sel f; End GetInfo("CountSelected") < 1, "No item(s) selected.";
   Global $files;
   $files = Report("{Dir |{FullName};{Ext}<crlf>|}", 1);
   Setting "AllowRecursion", 1;
   Sub "_ZERO";
   $files = RegexReplace($files, "^(.*);.*<crlf>", "$1|");
   Delete 1,1,$files;
   sel f; //selects all files, no folders.
   rename s, "-01/"

"_ZERO"
   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, ";");
   $newFile = RegexReplace($file, "$ext$", "$ext");
   New $newFile;
   $i = $i + 1;
   Sub "_ZERO";
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Ysl
Posts: 158
Joined: 03 Jan 2007 22:22

Re: Please help I need a Script !

Post by Ysl »

Hi all my helping friends !

I do have again a problem with this script, maybe because of a new update.

End GetInfo("CountSelected") < 1, "No item(s) selected.";
Global $files;
$files = Report("{Dir |{FullName};{Ext}<crlf>|}", 1);
Setting "AllowRecursion", 1;
Sub "_newTXT";
$files = RegexReplace($files, "^(.*);.*<crlf>", "$1|");
Delete 1,0,$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, ";");
$newFile = RegexReplace($file, "$ext$", "txt");
New $newFile;
$i = $i + 1;
Sub "_newTXT";
#1403

My problem is with command #1403 at the end of the script which is no more executed
#1403 is "Move to F:\Dummy Files"
Of course F:\Dummy Files exist and hadn't been changed.

So now the file is created as an .txt by the script but is not moved anymore to the F:\Dummy Files folder
Maybe there is another way to move the created .txt files by the script to that folder instead of using the #1403 command ?
Thanks for your help !
Ysl

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Please help I need a Script !

Post by highend »

Replace the line that contains "#1403" with

Code: Select all

moveto "F:\Dummy Files", $newFile
One of my scripts helped you out? Please donate via Paypal

Ysl
Posts: 158
Joined: 03 Jan 2007 22:22

Re: Please help I need a Script !

Post by Ysl »

Thanks ! Works fine for me !

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Please help I need a Script !

Post by j_c_hallgren »

Ysl wrote:I do have again a problem with this script, maybe because of a new update.
Please do all respondents a favor and always enclose any script code in "Code" tags...reading it otherwise is difficult at times.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

Post Reply