Jump to content
Macro Express Forums

dcman98

Members
  • Posts

    10
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by dcman98

  1. In Variables, choose Variable Set String. Then set the variable to use and "Set Value to File Name (Prompt)" This will open a file selection box.
  2. I copy and rename several hundred files a month, and since I'm doing data entry on them as well, I use Excel to duplicate my efforts. The basic way to do this is to have an excel sheet with a column of file names that you wish to copy, and if applicable, other columns with a new name, or a new destination folder. Have the Macro copy the contents of the first cell into a variable %T1%, move one cell to the right and put the new name into variable %T2%, then move one more cell to the right and set the new folder as variable %T3%, and then use the Copy File or Files command and set the Path to be C:\Offset File\1\%T1%.akx_phase, then for the new name, put in C:\%T3%\%T2%.akx_phase. This will copy the files to a new location. If your table were as follows: 1_1-18_0004s(25C) A Waffle 1_1-18_01876s(260C) B Waffle Then after running the macro, you could go to C:\Waffle, and find two files A.akx_phase and B.akx_phase Note: You will need to use the trim command on the variables to clean them up before you can use them in the name. If I recall correctly, the copied excel cell includes a carriage return. Edit: Another method just occurred to me, and it may work better if you're only doing one or two files, especially if they have long complicated names. You could use the Variable Set String and use Set Value to File Name (Prompt). This will open up a box for you to select the file, and set the filename to variable %T1%. Then use that same command and use prompt for value, then in that box type the new name you want and set that as varible %T2%. Then you could use the copy command with just %T1% as the name, and then put in the path you want to copy the file to, and append to that the %T2%.akx_phase Let me know how it works.
  3. I'd think that if you defined the text variable, then for the search text put in that variable with the required % signs around it, it would work. Test it out and let us know.
  4. If I understand correctly, this is a very straightforward process. There are files in a folder C:\files\documents and you want to copy them to C:\important\stuff (stuff will be that variable) First, you want to define a variable using the Variable Set String command, and set value T1 from prompt. Then you want to do a Copy File or Files command, where the first path is C:\files\documents and the new name is C:\important\%T1%\ Then when you run the macro, if you put in "stuff" into the prompt, it will copy the folder. There is also a checkbox to go into the subfolders if you want those too. David
  5. First, off, I'm going to say that it is probably easier to do this in excel. But you asked about ME, so here's how I would write it. Please understand that I am not a programmer, so I design my macros to be speedy representations of what a user can do with a mouse, keyboard, and basic thinking. Looking at your data, I noticed that the section truncated starts at the 7th space, but also at the 37th character. If this is always so, it makes your life that much easier, but if not, we can still make it work. The basic operation that I would do is line by line, rewrite the text document. I'll give you the broad strokes of my design here, and if you run into trouble, I can work out some of the details. I would use the home and shift+end keystrokes to set a line of text into a variable (T1), then truncate that variable into a new variable (T2), being only the first 4 characters. If that variable then matches "# CMP", then I know that the next line is the one I want to modify. If it is not, then I want to switch to a new text document, write T1, hit enter, and repeat. It may be good to use the idea of a switch here, where if T2="# CMP", then set T99 to A, and if not, set T99 to B. Then follow the next set of commands if T99 = A, but repeat the previous if T99 = B. If it does match, I still want to write T1 into my new document, but I don't want to just repeat the process. Instead, I want it to take the next line and make the whole line a variable, then remove the first 36 characters (if this varies, then use a process of finding the first space, removing it and everything before, and repeating 6 times to get to the spot you are looking for), then find the first space, then remove that and everything after that, being sure to save the first section, the second section, and the third section in different text variables. Then shorten the 2nd section to be 20 characters, then have the program go to the new text file and write all three sections, using the now modified 2nd section. Repeat this for every line of your document, and there you have it. To see how to find the space and crop a text string using other text, see this post: http://pgmacros.invisionzone.com/topic/5126-parse-data-from-text-file/?hl=%2Bfind+%2Btext+%2Bwithin+%2Bvariable#entry22039 Let me know if you need more detail or have any questions. David
  6. This may all be common knowledge to you, but if so perhaps it will help someone else. There is an ability to reduce a text variable by text strings, as a combination of several steps. 1) Put this text into a text variable 2) Set an integer variable (N1) based on the text string length. 3) Set another integer variable (N2) based on "Get position of text in a text variable", and set the text to find to be "MOVEREASON" 4) Select a third integer variable (N3) using Variable Modify Integer to be N1-N2 (the length of everything after your starting point) 5) Use Variable Modify String and select "Copy part of text" to modify the string. Use N2 as the starting position and N3 as the length. Then modify these steps so that it also removes everything after the piece you want. You will be left with just a text string that contains your data. Please note that these steps are the general steps to get your result, but not necessarily exactly what you need. For example, I believe that the result for N2 will actually give the character number for the M in MOVEREASON, so you may have to add a step to add a 13 to get to the actual starting character you want.
  7. Hi Shane, Although I'm no expert on this, I think that your problem is that the program sees N1 as a number, not as text. I did a little test myself, and could not get it to work as a number, but this did work. Before the rename step, insert this step: Variable Set String T1, choose Set Value Now, and for the value, put %N1%. Then change your rename step to use %T1% instead of %N1% (and lose the plus sign so it reads Scan%T1%.txt) This should do it for you. David edit: you may need to add a delay, or some query where it checks if the scan.txt file has been created. Otherwise, while the experiment is still running, the macro will move on and try to rename a file that isn't there yet.
  8. The way I determine my target files are by the extension. In my example, my macro uses an excel spreadsheet to change the file from D:\123456\R54wX.doc to C:\files from CD\123456_John Smith.doc The folder numbers (i.e. 123456) and client name are part of my spreadsheet, so the macro knows which folder is associated with which client. It then looks at the next line in the spreadsheet, gets the new number and name as variables, and uses the new number in the path to find the file. The difficulty I'm having is that each of the 200+ folders have 2 files in them, one .doc, and one .xls. In each folder, the files have the same name, but I don't know what that name will be, only the extensions. So to run this process, I currently have to browse the CD for the filename, then edit my macro to correct the filename for this CD. I hope that is more clear, and to specifically answer your question, I use 1 file out of each of the 200+ folders, and I know which file I want by the extension.
  9. Hello, I regularly receive a CD with a large number of files which must be reorganized into our system. I've been using Macro Express with great success for this, but there is one step which I'd like to automate. The folder structure of the CD is D:\123456 and in that folder there are two files, R54wX.doc and R54qw.xls. There are several hundred folders, and in each, there are these two filenames (though the files themselves have different contents). Each CD provides new random filenames, and I cannot see the reason behind the names. I would like to set a variable by the filename of the .doc file, but how can I get Macro Express to know which file I want? Thank you.
  10. Hello, I'm new to Macro Express and have had mixed results so far. I mainly use the software for file manipulation, moving and renaming, and using spreadsheets to bring additional data to the files. Currently, what I am working on is this. I have a file who's name is an account number only (ABC123456). Using a spreadsheet, I want to use variables to change the filename. The spreadsheet's columns are as follows: ABC123456 ABC-123456 Bob Smith I set the macro to use the arrow keys to select the first cell, then copy it to the clipboard, then set variable T1 from the clipboard. Then I give it a right arrow, again copy to clipboard, then set variable T2. I do the same to set variable T3. My understanding is that now T1=ABC123456, T2=ABC-1234356, and T3=Bob Smith. I was having quite a difficult time using these variables, so I gave myself a little doublecheck. I set the macro to go to another cell in Excel and then use the type text command and put in %T1%%T2%%T3%. I expected the variables to be in one cell, but instead each variable was in its own cell, in a vertical column, as if it had hit enter between each entry. Does anyone know if this is happening because of the way I set the variables? Using an If->Then statement, I can see that the next problem in my macro is getting it to find the file C:\test\%T1%.pdf When I use the actual value (ABC123456) instead of the variable, the macro works fine. I don't know if this not working is related to the way the variables expressed themselves in excel. The final piece, which may or may not work, is renaming the file to C:\test\%T2% %T3%.pdf It may be having the same issue as T1. If anyone has some idea on why the variables seem to be pressing enter, and what I can do to use a variable to rename a file, I would greatly appreciate the help. Thank you, David
×
×
  • Create New...