Jump to content
Macro Express Forums

trying to rename a file


patgenn123
 Share

Recommended Posts

Hello,

 

This should be simple.

 

I am trying to rename a file.

 

In my macro, I am declaring a variable to be taken from the window title into %T2%. Later I want to rename the file from E:\Personal Folders\RenderedPage.pdf to %T2%.pdf after the file was moved TO E:\Personal Folders using the Macro Express "Change Directory/Folder" function. It works up until it has to rename the file.

 

I keep on getting an error "There are one or more invalid cahracters in the file path. I am not seeing it. Where?

 

Essentially I am changing it from: E:\Personal Folders\RenderedPage.pdf to E:\Personal Folders\%T2%.pdf and %T2% has already been grabbed from the window title.

 

Help?

 

Pat

Link to comment
Share on other sites

For debugging, temporarily put a Text Box Display command before your rename attempt, to show you the value of %T2% that is being used. Bracket the T2 value with special characters so you can see whether there are trailing blanks; for example in the body of the text box put >>>%T2%<<<.

Link to comment
Share on other sites

I would check the complete filepath (not just %T2%) with a Text Box immediately prior to renaming. I always do that with file renaming until I'm sure it works OK, to avoid potential disaster. I think I normally would make the full filepath a new variable, say %T3% which I would use in the renaming. It would show all errors during the Text Box check. A fave mistake is to miss off the file extension of the fabricated filename. The file will be renamed but appear in an unexpected place in Explorer's listing.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...