Page 1 of 1

only names with number 0 appears on file

Posted: 07 Jul 2023 07:22
by guimcast@gmail.com
Hello!

$folder = get("SelectedItemsPathNames");
$filesinside = listfolder($folder, !"*.txt", 1, <crlf>);
$files = replace($filesinside, "\", "\\");
$textfileinside = $folder . "\filenames.txt";
$textfile = replace($textfileinside, "\", "\\");
writefile($textfile, $files);

I'm writing SelectedItemsPathNames of files(in subfolder) except for .txt of selected folder.

All fine, except for the fact that only files with 0 appear on the list, anyone knows the reason why?

from what i've tested:

xas\tires03\1_normal.jpg doesn't appear
xas\tires03\normal_123.jpg doesn't appear
xas\tires03\0_normal.jpg appears
xas\tires03\0123_normal.jpg appears
xas\tires03\normal_0123.jpg appears

appear - file path written to file
doesn't appear - file path not written to file

Any ideas? Thx!

Re: only names with number 0 appears on file

Posted: 07 Jul 2023 07:54
by jupe
listfolder doesn't accept boolean not, and you have it outside the quotes too, use an alternate method eg. quicksearch.

Re: only names with number 0 appears on file

Posted: 07 Jul 2023 17:36
by guimcast@gmail.com
Indeed! Thank you for the suggestion.

Posting the solution just in case another noob has the same doubt.

$folder = <curitem>;
$filesinside = quicksearch("*.jpg", $folder); // searching only for .jpg is ok for me.
$files = replace($filesinside, "\", "\\");
$textfileinside = $folder . "\filenames.txt";
$textfile = replace($textfileinside, "\", "\\");
writefile($textfile, $files); //

Re: only names with number 0 appears on file

Posted: 07 Jul 2023 18:27
by highend
In that case you could have just used listfolder($folder, "*.jpg", 1, <crlf>); as well^^

Re: only names with number 0 appears on file

Posted: 07 Jul 2023 19:14
by guimcast@gmail.com
Lol i agree with you.

Actually i just wanted to select the images files(in this case, all but .txt).

I ended up with:

$folder = <curitem>;
$filesinside = quicksearch("*.jpg;*.png;*.tga;*.tiff", $folder);

That way i know these are the only supported types, but i'd like to know how to use a file extension as exception. "!*.txt" doesnt work at all and I couldn't find another alternative.

I think quicksearch doesn't work with exceptions altho i remember to have seen it somewhere in the past :(.

Maybe I'm just tripping, thanks for dropping by anyways :)

Re: only names with number 0 appears on file

Posted: 07 Jul 2023 19:35
by jupe
Of course it works with exceptions, otherwise I wouldn't have suggested it.

Code: Select all

$filesinside = quicksearch("!*.txt /Efn", $folder);
but if you only want images anyway, then maybe this is better alternative in this case:

Code: Select all

$filesinside = quicksearch("{:Image} /fn", $folder);