Jump to content
Macro Express Forums

Macro to organize files and folders


Recommended Posts

I'm looking for a macro to help me organize files and folders on my desktop (D:\Desktop). Every file and folder that has a creation date older than 10 days would be placed in a folder called "Archive" (D:\Desktop\Archive). Within that folder, the macro would automatically group files into months based on their creation date. The folders would be named "YYYY-MM. The macro would monitor the desktop folder constantly and move files in real time or with a short delay, and temporarily skip a file that is currently being used and move it once available.

This seems like something fairly common, so I was wondering if anyone has done anything similar? Can it be done with Macro Express?

Link to comment
Share on other sites

The only aspect of your requirement that I think might be challenging stems from that word 'constantly'. I could see conflicts arising with the various background and housekeeping tasks of the OS. I'm curious why you'd need such a real time macro? How often do you edit the items in your Desktop folder?

 

I'm also unsure how I'd get MX Pro to intelligently delay the processing of entries that are currently in use, without unwanted interference with priority OS/File Explorer processes.

 

Terry, East Grinstead, UK

Link to comment
Share on other sites

The only aspect of your requirement that I think might be challenging stems from that word 'constantly'. I could see conflicts arising with the various background and housekeeping tasks of the OS. I'm curious why you'd need such a real time macro? How often do you edit the items in your Desktop folder?

 

I'm also unsure how I'd get MX Pro to intelligently delay the processing of entries that are currently in use, without unwanted interference with priority OS/File Explorer processes.

 

Terry, East Grinstead, UK

 

Hi Terry, thanks for your reply.

 

You may be right, but I don't see how consistent monitoring is a problem when it's only moving the files which are 10 days old. Knowing my routine, there is a very small chance that such file or folder would be accessed at that exact time. My workflow is very dynamic, so my desktop gets filled up quickly.

 

Can you explain how you handle everything but the things you're not sure about? I've done several macros up until now, but nothing too complex. This one I'm really not sure how to do.

Link to comment
Share on other sites

I'm away from home until next week, or I'd demonstrate. But start with the obvious steps

- Open the \Desktop using the Open Folder command.

- Read up on Repeat with Folder if you haven't used it before

- For each file, simulate the steps you'd perform manually to

--- Identify the 10 day old files.

--- Move them to the required folder.

Etc.

(This is proving harder than I expected without my PC! I'm sure someone will step in and amplify.)

 

Terry, East Grinstead, UK

Link to comment
Share on other sites

This can be done for sure. But I don't agree with Terry. He likes to use the Windows File Explorer interface to work with files and I like to process them invisibly in the background using the file manipulation commands. Look at the Repeat With Folder command to get started.

Link to comment
Share on other sites

I disagree with both Terry and Cory, but only because I'm difficult and hard to get along with. :P

 

I have done this in the past by having the macro run a batch file containing a couple commands:

cd\desktop path

dir /N /O > c:\temp\dirlist.txt

 

This produces a standard format directory list, with fixed columns for size, date, etc for each file.

 

Then your macro can read back the directory list file (ASCII FILE BEGIN PROCESS or TEXT FILE BEGIN PROCESS), analyze each line for date and size and whatever, and write a second batch file (VARIABLE MODIFY STRING APPEND TO TEXT FILE) containing DOS "move" commands to move the files and folders wherever you want them. In each "move" command include the option to ignore errors, so the whole batch file won't abort for a single file-move problem.

 

Finally, your macro can run the second batch file to actually move the files off the desktop.

 

If a file or two is passed over when the second batch file runs (due to being in use or whatever) it should be picked up next time your cleanup process runs.

 

Your cleanup macro can be scheduled to run at whatever frequency and interval you choose; or via a hotkey; or both. You might want to initially pop up a warning text box, so you know to stop typing while the cleanup process runs. That's one drawback of my method -- it doesn't happen invisibly in the background and your keyboard activity might interfere.

Link to comment
Share on other sites

Well OK then. I was trying to offer up a MEP solution, which can be done pretty easily IMHO, but if you want to start in with non-MEP solutions then I would write a PowerShell Script.

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...