Rename after Move

Discuss and share scripts and script files...
Post Reply
Quaraxkad
Posts: 125
Joined: 20 Apr 2014 18:01

Rename after Move

Post 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.

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

Re: Rename after Move

Post by highend »

Disable BackgroundFileOps via setting before executing that part of the script
One of my scripts helped you out? Please donate via Paypal

Quaraxkad
Posts: 125
Joined: 20 Apr 2014 18:01

Re: Rename after Move

Post 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.

Quaraxkad
Posts: 125
Joined: 20 Apr 2014 18:01

Re: Rename after Move

Post 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!

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

Re: Rename after Move

Post 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...
One of my scripts helped you out? Please donate via Paypal

Quaraxkad
Posts: 125
Joined: 20 Apr 2014 18:01

Re: Rename after Move

Post 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.

jupe
Posts: 2805
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Rename after Move

Post 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;

Quaraxkad
Posts: 125
Joined: 20 Apr 2014 18:01

Re: Rename after Move

Post 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;

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

Re: Rename after Move

Post by highend »

Maybe, just maybe... You post the full rename command you're using (FULLY RESOLVED)?

And rename isn't a function as well...
One of my scripts helped you out? Please donate via Paypal

Quaraxkad
Posts: 125
Joined: 20 Apr 2014 18:01

Re: Rename after Move

Post 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
Clipboard-1.jpg (170.29 KiB) Viewed 645 times
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.

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

Re: Rename after Move

Post by highend »

renameitem() doesn't support full paths for the newname argument, that's the reason

Comment out the ..."usecustomcopy"... line
One of my scripts helped you out? Please donate via Paypal

Quaraxkad
Posts: 125
Joined: 20 Apr 2014 18:01

Re: Rename after Move

Post by Quaraxkad »

OK, so back to moveto and then renameitem. Any idea why TeraCopy is taking over?

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

Re: Rename after Move

Post 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>"
...
One of my scripts helped you out? Please donate via Paypal

Quaraxkad
Posts: 125
Joined: 20 Apr 2014 18:01

Re: Rename after Move

Post by Quaraxkad »

Could I use moveas without using patterns, just feed it full source and destination paths?

Quaraxkad
Posts: 125
Joined: 20 Apr 2014 18:01

Re: Rename after Move

Post 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.

Post Reply