Code: Select all
foreach($item, <get selecteditemspathnames>, <crlf>, , "No files selected.") {
if (gpc($item, "ext") == "srt") {
rename , "*.en";
}
else {
msg "This is not an srt file";
}
}
Code: Select all
foreach($item, <get selecteditemspathnames>, <crlf>, , "No files selected.") {
if (gpc($item, "ext") == "srt") {
rename , "*.en";
}
else {
msg "This is not an srt file";
}
}
rename
?Thank highend, but that's far too cryptic. What exactly are you referring to in the rename entry? There's a lot there.
I don't appreciate you just assuming I haven't read that section. I HAVE! And I don't understand what part of it you are referring to. I can't see what applies to my code. Just because I'm not an expert like you doesn't mean I haven't tried to get it working myself.
Well I thought I had. I thought <get selecteditemspathnames> got all the filenames and then each $item that had the extension srt would be "given" to the rename function. Apparently that's not right cos it doesn't work but I'm really struggling trying to fix it when I don't really know which part of my code isn't working.
Thanks Don, I had a look at that section and I thought changing
Code: Select all
rename , "*.en";
Code: Select all
renameitem("*.en",,1);
Code: Select all
foreach($item, <get selecteditemspathnames>, <crlf>, , "No files selected.") {
if (gpc($item, "ext") == "srt") {
rename , "*.en", , $item;
}
else {
msg "This is not an srt file";
}
}
Oh my gosh, thank you so much! I feel a bit of an idiot now, it was such an easy fix. But it just goes to show how we can all read things differently. I knew what you were getting at but I couldn't see how it related to what I was doing wrong. Your patience and explanation are very much appreciated.jupe wrote: ↑22 Oct 2021 01:23 I thought I gave you a clue to what part of your code isn't working, by indicating you weren't supplying rename with a filename, anyway below is a modded script, which provides a filename to rename, because without it rename processes the whole selection, which is also mentioned in the documentation you read.
This could also be done without a foreach, but I'll leave it as is.Code: Select all
foreach($item, <get selecteditemspathnames>, <crlf>, , "No files selected.") { if (gpc($item, "ext") == "srt") { rename , "*.en", , $item; } else { msg "This is not an srt file"; } }
rename , '*.en', , formatlist(<selitems |>, 'f', , '*.srt');
I don't appreciate you just assuming I haven't read that section. I HAVE! And I don't understand what part of it you are referring to. I can't see what applies to my code
If empty then current list selections are renameditemlist CRLF- or |-separated list of items (full path) to rename. If empty then current list selections are renamed. The separator may be surrounded by any number of blanks.
Oh geez, my brain must be taking a coding break. I didn't even consider that. Gona go give myself a jolly good talking to!