Page 1 of 1

Rename after Move

Posted: 08 Jan 2024 00:26
by Quaraxkad
I have as script that uses moveto to move a file from one folder to another, and the next line is renameitem to rename that file in the destination. The renameitem function fails with the error "Did not find: sourcefilepath.ext" unless i put a wait inbetween. I suspect it's because XY is passing the move operation off to either the shell or my custom copier TeraCopy. In that case the renameitem function is running before the movie actualy happens. The documentation suggests that it will use internal copy functions if/when using the on_collision flags for moveto, I am using those flags but the problem remains. Any ideas?

Code: Select all

moveto($moviefolder."\Extras\", $file, , 2, 2, -1, 1, 0, 0, 0, 1, 1); //move file to destination
renameitem($destname, $moviefolder."\Extras\".$filename, 4); //rename to final filename, prompt if file exists
I have confirmed 100% that the variables are correct, the file exists in the exact path that is being used by renameitem.

Re: Rename after Move

Posted: 08 Jan 2024 00:29
by highend
Disable BackgroundFileOps via setting before executing that part of the script

Re: Rename after Move

Posted: 08 Jan 2024 00:52
by Quaraxkad
I added setting BackgroundFileOps, 0; just before the moveto, same result.

EDIT: I should note I'm not using the current version of XY, maybe it's a bug that's been fixed. I'll try the newest release.

Re: Rename after Move

Posted: 08 Jan 2024 00:59
by Quaraxkad
OK, it DOES work in the latest version, though it gave me an error on the settings line, so I changed it to

Code: Select all

setting("BackgroundFileOps", 0);
. It still does not work in the old version I'm using, so it's probably a bug and I need to update!

Re: Rename after Move

Posted: 08 Jan 2024 01:18
by highend
It's setting "BackgroundFileOps", 0;
It's not a function, it doesn't have a return value

A bug? More probably it just didn't exist in that <whatever version you use>

@Don
You should change the docs to make it clear that the name argument belongs into (double) quotes...

Re: Rename after Move

Posted: 08 Jan 2024 01:42
by Quaraxkad
OK, thanks. I've removed the parenthesis. But now it seems to have stopped working again, using the latest beta version...

Is there no move AND rename function? That would be so much better.

Re: Rename after Move

Posted: 08 Jan 2024 02:20
by jupe
You can, but need to make sure it is enabled first,

Configuration | General | Sort and Rename | Rename | Allow move on rename

then you can do it something like this:

rename l, $moviefolder."\Extras\".$destname, , $file;

Re: Rename after Move

Posted: 08 Jan 2024 22:19
by Quaraxkad
jupe wrote: 08 Jan 2024 02:20Configuration | General | Sort and Rename | Rename | Allow move on rename

I wasn't aware of that option, thanks! That's super helpful for some other things I need, but it doesn't seem to work here. Or maybe a diference between rename() and renameitem()? It returns "The new name has invalid characters". The destination does include the full drive path, that colon is the only "invalid" char, maybe it only works to move into a subfolder and not another drive?

I have confirmed that TeraCopy is STILL doing the move operation, even though the first line of my script is

Code: Select all

 setting "BackgroundFileOps", 0;

Re: Rename after Move

Posted: 08 Jan 2024 22:37
by highend
Maybe, just maybe... You post the full rename command you're using (FULLY RESOLVED)?

And rename isn't a function as well...

Re: Rename after Move

Posted: 08 Jan 2024 22:45
by Quaraxkad
Does this help? Sorry the window is so large, I couldn't resize it. There's more to the script, but it looks like XY only displays lines it had to execute.
Clipboard-1.jpg
I wonder if it's not actually invalid characters, but instead it's expecting the destination folder to already exist? moveto doesn't have that restriction.

Re: Rename after Move

Posted: 08 Jan 2024 22:53
by highend
renameitem() doesn't support full paths for the newname argument, that's the reason

Comment out the ..."usecustomcopy"... line

Re: Rename after Move

Posted: 08 Jan 2024 22:54
by Quaraxkad
OK, so back to moveto and then renameitem. Any idea why TeraCopy is taking over?

Re: Rename after Move

Posted: 08 Jan 2024 23:07
by highend
I'm not using an external file handler...

You could also prepare a .bat / .cmd file from your script and run that

Code: Select all

MKDIR "<destination folder 1>"
MOVE /Y "<src file with full path 1>" "<dst file with full path 1>"
MKDIR "<destination folder 2>"
MOVE /Y "<src file with full path 2>" "<dst file with full path 2>"
...

Re: Rename after Move

Posted: 09 Jan 2024 18:10
by Quaraxkad
Could I use moveas without using patterns, just feed it full source and destination paths?

Re: Rename after Move

Posted: 10 Jan 2024 01:38
by Quaraxkad
I figured out a solution... Instead of using just

Code: Select all

setting "BackgroundFileOps", 0;
I also used

Code: Select all

 copier("");
I may not even need the backgroundfileops setting.