Macro Toolworks Products Discussion Forums :: FAQ's
Welcome Guest   
 Subject :Q: How to Check if the current letter it a number?.. 31-08-2010 14:45:39 
bla.blub@gmx.de
Joined: 23-08-2010 20:13:26
Posts: 3
Location
Hi,

i tryed to automaticly rename all files in the folder.
the problems is the files have not the same amount of numbers and i want to keep the numbers and replace everything else with a word that is enterd on the beginning


i tryed:

to copy every latter after another and check (if_str) 1;2;3;4.... and with x==1) _OR_ ....
but when a letter and not a number comes wo won´t exit the loop.

1/4 of my code remains if iam gonna directly copy it in here even it it is tagged as so i attached the macro as txt and a screenshot of the text[code]
so i attached the macro as txt and a screenshot of the text

IP Logged
 Subject :Re:Q: How to Check if the current letter it a number?.. 02-09-2010 10:44:32 
petr
Joined: 15-10-2009 11:48:52
Posts: 131
Location
Hello,

I modified your macro because I found there is problem with _OR_ and _AND_ (which we will fix in next release). The modified macro changes file name based on the user's input this way: If user specifies the new file name will be "Gerda" then the
file with name "102347Trudy.txt" will be changed to "102347Gerda.txt". Just run the macro below when you have the file selected in Windows Explorer (I have tested it on Windows 7).

<#> Enter Name
<cmds><varset>("name=","Namen Eingeben")
<#> Start edit filename
<keys><F2><cmds><wx>(250)

<#> Copy the file name to clipboard
<clp_copyselected>(0,5)

<#> Set helper variables: old name, new name, string length
<varset>("vOldName=_vClpText","")
<varset>("vNewName=_vStrEmpty","")
<varset>("vNumbers=0123456789","")
<var_oper>(vOldNameLength,"%vOldName%",STR_LENGTH,"2","", "0")

<#> Copy all numbers from old name to the new name in the cycle and when the number section ends stop the cycle
<for>("i=0","i<vOldNameLength","1")

<var_oper>(vOldNameChar,"vOldName",STR_GET_CHAR,"i","", "0")

<if_str>("vNumbers~=vOldNameChar")
<var_oper>(vNewName,"%vNewName%",STR_APPEND,"vOldNameChar","", "0")
<else>
<#> End of numbers, append user defined new name and stop the cycle
<var_oper>(vNewName,"%vNewName%",STR_APPEND,"name","", "0")
<for_break>
<endif>

<for_end>

<#> Set new file name
<varout>("vNewName",0)
IP Logged
 Subject :Re:Q: How to Check if the current letter it a number?.. 06-09-2010 14:26:42 
bla.blub@gmx.de
Joined: 23-08-2010 20:13:26
Posts: 3
Location
thx for all your efforts, we are running here windows vista and windows 7 so it will work.

thanks again :)
IP Logged
Page # 


Powered by ccBoard


Login and share your experience - send messages to forums and add comments to samples, commands and other resources.



Account is free of charge, easy to setup.