Rename file

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Rename file

Post by Grovkillen » Wed Dec 02, 2020 9:19 am

If I have a fairly long file path and would like to rename it I get the "max path" error (CF_RESULT_CODE=183). How should I go about this?
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Rename file

Post by Grovkillen » Thu Dec 03, 2020 10:06 am

Found a solution. Using Python:

Code: Select all

/*
python_code_copy_file:
import shutil
source = r'%PY_COPY_FILE_SOURCE%'
target = r'%PY_COPY_FILE_TARGET%'
shutil.copyfile(source, target)
*/
LabelToVar>python_code_copy_file,py_copy_file
PyExec>py_copy_file,temp
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Rename file

Post by Grovkillen » Thu Dec 03, 2020 10:15 am

Well, I asked for rename... here's the rename variant:

Code: Select all

/*
python_code_rename_file:
import os
os.rename(r'%PY_RENAME_FILE_SOURCE%',r'%PY_RENAME_FILE_TARGET%')
*/
LabelToVar>python_code_rename_file,py_rename_file
PyExec>py_rename_file,temp
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
PepsiHog
Automation Wizard
Posts: 511
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Rename file

Post by PepsiHog » Tue Dec 22, 2020 9:43 pm

I think this may be useful and relevant. I recently learned about a command called robocopy. It doesn't have the long path issue. Haven't used it as of yet. You'd think they'd just fix the issue instead of making a separate command to overcome it. But that's what Microsuck does.

PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2021) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: Rename file

Post by Grovkillen » Wed Dec 23, 2020 6:19 am

Ah, thanks. I'm going to test that next time.
Let>ME=%Script%

Running: 15.0.24
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts