Rename then copy MOVE a file fails because windows still thinks file has old filename

Just add the destination folder to the Rename command:

cmd.RunCommand('Rename PATTERN=(.*) TO="/Work\\\\1 SUFFIXXX" REGEXP IGNOREEXT');

1 Like

Thanks @Pro Any idea how to do that?
I will probably go with @Ixp suggestion below but I am curious....

I see....this is the FILE switch from the copy commandL

@Ixp thanks. When I do that Opus create a subdirectory in the source folder and move the folder there instead of using the alias as intended. I have looked in the rename notes but I see no clarifying notes. Ideas?

Try replacing /work with {alias|work}.

Thanks @Ixp
I got some wierd results with the script see Test 10.
I ran the command via the FAYT prompt as you can see in Test 11 got something different again.
I really appreciate your help and I don't want to burn your time unnecessarily.
Let me retreat, take a break, and then check things out again.
I got help from @Leo a while ago with my Lister not refeshing issue mentioned above and I need to be more sure that it is not my end/my laptop etc. and is causing issues.
The thing that is in front of my mind is that my script has worked for many months/years maybe then started playing up. Symptoms vary alot and do not point in one direction. Below is another example of this. Not making sense at the moment.
Really really appreciate your help.

======================================================================

Ah yes... forgot something... {alias|work|escbackslash} should do it right.

Interesting.
I searched escbackslash and found a hit in Opus help page External control codes.
Is that what these things are?

Test 12 below with {alias|work|escbackslash} is the same result as Test 11.
At least I have consistency now.

So let us examine the (Test11/Test12) result.
The intention is to add a suffix.
The use of \1 in the Regular Expression is intended to act as a capture group referencing the original filename.
However this is being interpreted as a literal digit 1 as you can see below.
I tried removing one of the backslashes in the TO expression but no joy..

I use regex because it is powerful and I am used to it but at this stage I will take any solution :slight_smile:
BEFORE = Filename.ext
AFTER = Filename SUFFIX.ext

Ok... how about {alias|work|escregex}? Well, it probably won't work either.

Aliases and Regex probably won't mix well here :frowning:

I guess we need to either use a non-REGEX rename or switch to Copy MOVE.

I think this is solved. See below.
Fix on above is to add a space shown in what color is that? Light turquois?
I dropped it before troubleshooting.
Makes sense that it should be there.

What a mission. Thanks @Ixp - I was hopelessly lost... really really grateful.

Did not see this :slight_smile: before I posted.
A few closing questions if I may be so bold.

  1. The fix you gave me effectively adds a move function to the rename function.
    Is that documented there? I cant find anything
  2. The use of External Control Codes for passing filenames also... are "used to pass information like the names of selected files to external programs." Not strictly true then?

Either way really chuffed with this outcome it was crashing my life!! Thanks!!!!

Ad 1: Well, that's in Rename's DNA. You can completely change a file's path from Drive to Extension and all folders in between. Even if you only create a subfolder the file already gets not just renamed but moved as well.

Ad 2: Not true in the sense that it's only for external programs? I have never tried to insert a code like {allfilepath} into a rename statement, but it would probably work ...somehow :wink:

1 Like

Just when you thought it safe.
I have something close to a solution above thanks to great help from @Ixp
Question - Is it possible to add the ASK: feature so that the Select Destination Folder dialog, shown below, is brought up?
Or am I finally "asking" too much sorry terrible pun :slight_smile:

image

Like so?

Rename PATTERN=(.*) TO="{dlgfolder|Your choice!|/Work|escregex}\\1 SUFFIXXX" REGEXP IGNOREEXT

Thanks @Ixp. Unfortunately we have a windows error again.
I wonder if dlgfolder is passing the entire path? That might break things if so?

I think Lxp’s command is meant for the script. If you’re running it directly it won’t work because the backslash is escaped for JScript.

Looks like there’s also an extra space in your command before the backsashes.

(last edit?)

  • remove the space
  • add a p to escregex: escregexp
  • use 2 backslashes in a button, 4 in a script

Gentlemen
I have got your string @Ixp to work in script and FAYT as per below.
Thank you so much I thought I was doomed to fail at the last hurdle!
Now I can fix my script.
My repeats of thank you seem inadequate somehow but I give them anyway!

I still recommend you at least try the first two bullet points :slight_smile:

Yes I did wonder about them. Sometimes these command strings have worked then stopped.
I have seen them work with 2 backslashes before on FAYT and now they do not for example.
the first 2 bullet points are

  • Remove the space - I have tried that and it breaks.
  • Add a p toe escregex for give escregexp

Once again..... thank you