kgibbs Posted July 5, 2010 Report Posted July 5, 2010 Question: If all file names in a given folder are integers: (How do I get the largest integer folder name or the last file “name/integer” created?) Macro Description: Using the middle mouse button, individually select and save source files to given folder and name them using integers starting with 0001 counting by step 1 until folder reaches 9999. Note: The folder will be populated over time as the source files are created one at a time using a hotkey activated by the middle mouse button. Macro needs to continue counting from last integer step folder name! I'm not sure how to get the macro to always start counting from the last created integer folder name? Any advice very appreciated! Thanks, Kurt Quote
paul Posted July 6, 2010 Report Posted July 6, 2010 Question: If all file names in a given folder are integers: (How do I get the largest integer folder name or the last file “name/integer” created?) Macro Description: Using the middle mouse button, individually select and save source files to given folder and name them using integers starting with 0001 counting by step 1 until folder reaches 9999. Note: The folder will be populated over time as the source files are created one at a time using a hotkey activated by the middle mouse button. Macro needs to continue counting from last integer step folder name! I'm not sure how to get the macro to always start counting from the last created integer folder name? I'm confused as to whether you want to return the largest integer folder name, or the largest integer file name! Quote
acantor Posted July 6, 2010 Report Posted July 6, 2010 Consider storing the most recent file name in an .ini file or in the registry. Quote
Cory Posted July 6, 2010 Report Posted July 6, 2010 I too am confused but if you want to get the name of the last file in a folder you can simply use the Repeat With Folder command with nothing in it. When it's done the last file name will be saved in the variable. Quote
paul Posted July 6, 2010 Report Posted July 6, 2010 I too am confused but if you want to get the name of the last file in a folder you can simply use the Repeat With Folder command with nothing in it. When it's done the last file name will be saved in the variable. I think that NTFS will always return filenames in alphabetical sequence, but I don't think FAT or FAT32 do. Quote
Cory Posted July 6, 2010 Report Posted July 6, 2010 Fair comment. However I haven't seen a FAT32 partition in... [sharp inhale] Geez, I can't remember. Hence I wouldn't be familiar with the behavior. Quote
kevin Posted July 6, 2010 Report Posted July 6, 2010 Some (all?) USB flash drives are formatted with FAT32. Large hard drives are, necessarily, formatted NTFS. My Network Accessible Storage (NAS) drive had to be formatted with EXT3 format due to the device that connects it to the network. Whether or not files are returned in alphabetical order depends on how the drive is formatted. FAT32 returns files in the order they were first created (unless they are deleted and/or moved). NTFS returns files in alphabetical order. I have not tested to see if EXT3 or other formats return files in creation or alphabetical order. Quote
kgibbs Posted July 7, 2010 Author Report Posted July 7, 2010 Thanks to ALL for your generous support and helpful ideas! Sorry I made this confusing by stating “folder” and not “file” throughout my question: I'm not sure how to get the macro to always start counting from the last created integer “folder” name? Solution: I used Alan’s idea that pointed me to borrow code from a sample macro “from_run_to_run.” Basic testing: - Using iExplorer <MM-Click> on pictures to auto-save them to My Documents incrementally starting with 1. Notes: - Not the initial purpose, but I see this is super fast for saving pictures from the internet to My Documents - NICE! - Reset naming counter by clearing the data in “counter.TXT“ - Windows defaults “Save As” to My Documents Macro Activation: MM Mouse button <LOCK PLAYER Wait="TRUE"/> <COMMENT/> <COMMENT Value="Initialization"/> <VARIABLE SET STRING Option="\x00" Destination="%T[1]%" Value="D:\\n1\\Database\\temp"/> <VARIABLE SET STRING Option="\x00" Destination="%T[2]%"/> <VARIABLE SET INTEGER Option="\x00" Destination="%N[1]%" Value="0"/> <COMMENT/> <COMMENT Value="Get counter value from file"/> <VARIABLE MODIFY STRING Option="\x06" Destination="%T[1]%" Value="\\counter.TXT"/> <IF FILE EXISTS File="%T[1]%" Search_Path="FALSE"/> <VARIABLE SET STRING Option="\x03" Destination="%T[2]%" Filename="%T[1]%" Strip="FALSE"/> <ELSE/> <VARIABLE SET STRING Option="\x00" Destination="%T[2]%" Value="0"/> <END IF/> <COMMENT/> <COMMENT Value="Increment counter"/> <VARIABLE MODIFY STRING Option="\x04" Destination="%T[2]%" Variable="%N[1]%"/> <VARIABLE MODIFY INTEGER Option="\x00" Destination="%N[1]%" Value1="%N[1]%" Value2="1"/> <VARIABLE MODIFY INTEGER Option="\x04" Destination="%N[1]%" Variable="%T[2]%"/> <COMMENT/> <COMMENT Value="Mouse right click and save as"/> <MOUSE RIGHT CLICK/> <TEXT TYPE Action="0" Text="S"/> <TEXT TYPE Action="0" Text="%N[1]%"/> <TEXT TYPE Action="0" Text="<ENTER>"/> <COMMENT/> <COMMENT Value="Copy counter value to the clipboard"/> <CLIPBOARD START COPY/> <TEXT TYPE Action="0" Text="%T[2]%"/> <CLIPBOARD END COPY/> <COMMENT/> <COMMENT Value="Copy the counter value from the clipboard into the file containing the counter"/> <CLIPBOARD SAVE TEXT Filename="%T[1]%" Prompt="FALSE"/> <COMMENT/> <UNLOCK PLAYER/> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.