Jump to content
Macro Express Forums

Percent % character and creating/deleting/renaming/copying/moving files and folders


Recommended Posts

Dear All,

Percent characters are used as variable identifiers within macro express.

I'm experiencing problems in creating/deleting/renaming/copying/moving files and folders containing multiple % characters somewhere in their path/name.

I've found 2 relevant threads, but the techniques used in there don't work when creating/deleting/renaming/copying/moving files and folders, because variables are evaluated in these commands.

Therefore if I come across a path, a path with a filename, or a filename, containing more ten 1 % character, a "Variable Not Set or Incorrect Variable Type" error occurs.

Example of such path with filename:
d:\801% SampleDVD\SubFolder1\SubFolder2\80% SampleDVD%.mp4

I've tried using the split command to assure only 1 % character, but as soon as I compile the complete path again, and start doing whats needed with the file or folder, the error's back.

 

I've tried doubling the percent character, so %%, instead of %. I can't find it anymore, but I remember reading somewhere that the % characters will then be interpreted as character, not variable. Unfortunately also no go.

I've also tried renaming files and folders, by replacing the % character with something else. In itself that works, but going back again later to the original name will again cause errors.

Apart from that, I couldn't find a way around the possibility of 2 % characters in a filename or foldername, e.g. "80% SampleDVD%.mp4".

-How do you people deal with this, might you have some ideas?

Thanks and best regards,

Link to comment
Share on other sites

I assume the percents in file names are extant and can not be anticipated.

 

What command are you having a problem with specifically? For instance I just created a file named "Some %UndefinedVariable% Again.txt" and stuck it on the desktop and executed a Repeat with Folder command coupled with a Text Box Display in the loop of see each file and it work fine.

Repeat with Folder C:\Users\Cory.BD\Desktop
  Text Box Display: Test
End Repeat

I suggest you create a simple macro that demonstrates the problem and post it here for us to test ourselves.

Link to comment
Share on other sites

Looking only at the rename command I can't figure out a way to do it within MEP. No matter how one gets the name as long as you use the MEP Rename command it will attempt to evaluate variables in the extant file name. I can think of several ways to do it with external scripts or whatever but not from within MEP. It seems to me that the file manipulation commands need an option not to process embedded variables as well.

 

Don't forget you can at least catch this error and handle it. Maybe make an external script that will fix that file name for you.

 

You know we have had this problem before and I appreciate the option not to process embedded variables but I wonder if at times we need a hybrid. That is to processes embedded variables only if they exist and otherwise ignore. I think I'll make that suggestion officially at the ISS site.

Link to comment
Share on other sites

Thanks Cory,

 

I was afraid of this already, and am now looking into creating a DOS batch file to rename/restore folder/file names again. I hadn't given it a serious go, because from the several thousands of folders/files, it's only about 319 that need this treatment. To much to do it manually though.

 

It's a good idea though to use that in the catch error part, thanks for that. I hadn't thought about that to be honest, as I try in general to be ahead of problems, not to react to them. It often makes things overly complicated for me, but I learn from that. I'll give that a go as well.

 

As you wrote though, not to process embedded variables if they don't exist, would in my opinion be the 1 that would solve most of the problems experienced, if not all. It shouldn't be too difficult to implement as well.

 

Best regards,

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...
×
×
  • Create New...