Jump to content
Macro Express Forums

Challenge: a macro to create new files and/or folders in Windows File Explorer


Recommended Posts

The Windows 10 "File Explorer" (aka "Windows Explorer" in earlier version of Windows) is a file manager application. It is used to navigate around a computer; open, delete, and rename files and folders; and create files and folders. (It has other uses, but we don't need to consider these now.)

 

In the world of Windows hotkeys, Ctrl + N is usually reserved for creating something new. ("N" stands for "New.") For example, in Microsoft Word, pressing Ctrl + N creates a new document. In Outlook, Ctrl + N creates a new email message. In browsers, Ctrl + N opens a new web page.

 

In File Explorer, Ctrl + N creates a new instance of the current folder. This is something I rarely do. For me, a better use of Ctrl + N would be to create a new folder... or a new Word document... or a new text file.

 

The Challenge, Part 1:

 

Create a macro triggered by Ctrl + N that is recognized only in File Explorer. The script either creates a new folder or a new document.

 

The Challenge, Part 2:

 

The macro offers a choice of whether to create a new file or a new folder.

 

Your script should work regardless of how a user has configured File Explorer. It should work equally well when the Ribbon, Navigation Pane, Preview Pane, and Details Pane are hidden or visible.

Link to comment
Share on other sites

  • acantor changed the title to Challenge: a macro to create new files and/or folders in Windows File Explorer

Hi Terry,

 

Due to computer overuse injuries, I rarely use a mouse -- other than when I scroll and zoom via mouse wheel. (In many applications, I have hotkey-triggered macros to scroll and zoom!) So I don't habitually think about clicking, double-clicking, and right-clicking.

 

The point of this macro is to eliminate or minimize the need for precision hand movements associated with mousing. Pressing a hotkey doesn't require pixel-level accuracy: the action is performed exclusively with gross motor movements.

Link to comment
Share on other sites

Hi Alan,

 

Thanks, understood.

 

But why not simply use Shift+F10 > W in the parent folder? And then either

Enter to create a new folder

Arrow Down or Arrow Up an appropriate number of times to choose file type

 

Terry

 

 

Link to comment
Share on other sites

Terry,

 

It hadn't occurred to me to simulate a right-click while the list of folders/files has focus!

 

But curiously, on my Windows 10 system, the context menu that appears after right-clicking (or pressing Shift + 10) has NO options for creating a new folder or a new file!

 

image.thumb.png.d12fa3792dde2d1b5b6e0b5e7d667752.png

 

Even if the context menu did always include commands for creating new files and a new folder, the script might fail when the list of folders/files isn't focused. For example, if the Address bar or the Search bar are focused, do the same options appear in the context menu? They don't on my computer.

 

It's odd that my context menu for the main explorer.exe UI would be different than your context menu. In earlier versions of Windows, context menus items were in an ordinary folder, so it was possible to customize the menu by adding and deleting items to that folder. I've had this computer for less than a year, and I don't think I modified that folder! But maybe inadvertently?

 

And what if the context menu approach to solving this challenge is an inherently unreliable method?

Link to comment
Share on other sites

Hi Alan,

 

But curiously, on my Windows 10 system, the context menu that appears after right-clicking (or pressing Shift + 10) has NO options for creating a new folder or a new file!

 

I think you've selected a folder before clicking in an empty area of the current folder (or hovering there and using Shift+F10).

 

I do have an especially large context menu, but I think New is standard.

 

Let's clear that up first before moving on to your other points.

 

 

Link to comment
Share on other sites

Ah... now I see... there are two different context menus, and the behaviour of these context menus is different when it's opened with the keyboard or with the mouse.

 

So there are two factors that influence the context menu in File Explorer: which object has keyboard input focus; and how the context menu is opened: keyboard or mouse.

 

Via keyboard, if a file or folder has focus:

Ctrl + spacebar

Shift + F10

 

Via keyboard, if the list itself has focus (i.e., a file or folder doesn't have focus):

Shift + F10

 

Via the mouse:

Right-click within the listview in a region devoid of other objects!

 

Given these Windows idiosyncrasies, it will be challenging to script a macro for explorer.exe that creates a new file or folder, and does so reliably.

Link to comment
Share on other sites

If no assumptions can be made about the starting conditions (such as what, if anything, is already selected) I'd try something like this:

 

1. From the folder's dimensions, calculate the position of the point 10px from the its left edge and 90 px from its bottom edge, which should always be empty.

2. Left click and use Shift+F10, or use right click, to open the context menu, followed by W to open the New menu.

3. Then pop-up a message or multiple choice dialog allowing the choice of Enter for a folder or whatever types of 'a file' you are offering.

 

 

Link to comment
Share on other sites

Hi Terry,

 

I tried your solution (which is in the "class" of solutions that I also I sometimes use: "start by clicking in a neutral part of the screen...")

 

Variable Set Integer %Height%: Set to the Current Window's Height
Variable Modify Integer: %Height% = %Height% - 90
Mouse Move: 10, %Height% Relative to Current Window
Mouse Right Click

etc.

 

 

The mouse pointer was too close to the border of the window to activate the context menu. I have slightly enlarged screen fonts -- I set them in the Windows display settings. This probably increases the thickness of the window border.

 

So I changed "10" pixels to "20" and the macro worked!

 

But then I positioned the window "westward" so the window's left edge was slightly off screen. The macro failed. Instead, the other context menu appeared -- the one that doesn't include "New..."

Link to comment
Share on other sites

Here's my solution. Since I began using it it last week, I've used it every day, so I'm finding it really useful.

 

How it works: The script sends sequences of keystrokes that interact with File Explorer's ribbons and menus.

 

You may need to make minor edits to this script to make it work on your computer: Adjust the number of UP and DOWN arrow key instructions, as noted in the script.

 

I've set this script is be triggered with Ctrl + N, but of course you can make it anything that you want. When activated, you are offered a choice: create a new folder, a new Word file, a new text file, or "Other." If the latter, the script displays the menu that contains the list of objects that can be created, and then stops.

 

 

// In Windows Explorer, create a new folder, Word document, or text file
// You will probably need to adjust the number of UP and DOWN arrow keys in this script
// See comments embedded in script
 
Variable Set String %Choice% to "Folder"
Multiple Choice Menu: New Folder or File
 
Switch( %Choice% )
Case: Folder
  Text Type (Simulate Keystrokes): <ALT>
  Text Type (Simulate Keystrokes): h
  Text Type (Simulate Keystrokes): n
End Case
 
Case: Word document
  Text Type (Simulate Keystrokes): <ALT>
  Text Type (Simulate Keystrokes): h
  Text Type (Simulate Keystrokes): w
  // Adjust number of <UP ARROW> and/or <DOWN ARROW DOWN> based on how your PC is configured
  Text Type (Simulate Keystrokes): <ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN>
  Text Type (Simulate Keystrokes): <ENTER>
End Case
 
Case: Text file
  Text Type (Simulate Keystrokes): <ALT>
  Text Type (Simulate Keystrokes): h
  Text Type (Simulate Keystrokes): w
  // Adjust number of <UP ARROW> and/or <DOWN ARROW DOWN> based on how your PC is configured
  Text Type (Simulate Keystrokes): <UP ARROW><UP ARROW><UP ARROW>
  Text Type (Simulate Keystrokes): <ENTER>
End Case
 
Default Case
  Text Type (Simulate Keystrokes): <ALT>
  Text Type (Simulate Keystrokes): h
  Text Type (Simulate Keystrokes): w
End Case
End Switch

    
<COMMENT Value="In Windows Explorer, create a new folder, Word document, or text file" _BACK="0080FFFF"/>
<COMMENT Value="You will probably need to adjust the number of UP and DOWN arrow keys in this script" _BACK="0080FFFF"/>
<COMMENT Value="See comments embedded in script" _BACK="0080FFFF"/>
<COMMENT/>
<VARIABLE SET STRING Option="\x00" Destination="%Choice%" Value="Folder" NoEmbeddedVars="FALSE"/>
<MULTIPLE CHOICE MENU Style="\x00" Result="\x01" Dest="%Choice%" Title="New Folder or File" Prompt="Create a..." Options="Folder\r\nWord document\r\nText file\r\nOther..." Left="727" Top="356" Monitor="0" Width="270" Height="223" OnTop="TRUE" Columns="Auto"/>
<COMMENT/>
<SWITCH Variable="%Choice%"/>
<CASE Value="Folder"/>
<TEXT TYPE Action="0" Text="<ALT>"/>
<TEXT TYPE Action="0" Text="h"/>
<TEXT TYPE Action="0" Text="n"/>
<END CASE/>
<COMMENT/>
<CASE Value="Word document"/>
<TEXT TYPE Action="0" Text="<ALT>"/>
<TEXT TYPE Action="0" Text="h"/>
<TEXT TYPE Action="0" Text="w"/>
<COMMENT Value="Adjust number of <UP ARROW> and/or <DOWN ARROW DOWN> based on how your PC is configured"/>
<TEXT TYPE Action="0" Text="<ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN>"/>
<TEXT TYPE Action="0" Text="<ENTER>"/>
<END CASE/>
<COMMENT/>
<CASE Value="Text file"/>
<TEXT TYPE Action="0" Text="<ALT>"/>
<TEXT TYPE Action="0" Text="h"/>
<TEXT TYPE Action="0" Text="w"/>
<COMMENT Value="Adjust number of <UP ARROW> and/or <DOWN ARROW DOWN> based on how your PC is configured"/>
<TEXT TYPE Action="0" Text="<UP ARROW><UP ARROW><UP ARROW>"/>
<TEXT TYPE Action="0" Text="<ENTER>"/>
<END CASE/>
<COMMENT/>
<DEFAULT CASE/>
<TEXT TYPE Action="0" Text="<ALT>"/>
<TEXT TYPE Action="0" Text="h"/>
<TEXT TYPE Action="0" Text="w"/>
<END CASE/>
<END SWITCH/>

 

Link to comment
Share on other sites

Hi Alan,

 

After adjusting the number of arrow  up/down steps your macro worked fine here, although I didn't have time to test all the pane and ribbon configurations.

 

One thing that I'd assumed from your description was that it should behave the same regardless of what was selected or focused in the target folder. IOW, the same behaviour as the built-in right click behaviour. But I see that if a subfolder is selected then the new element is created in that, not in the open folder. Or was that your intention?

 

BTW, isn't it curious that our versions of MX Pro use different command text 🙂

 

  Text Type (Simulate Keystrokes): <UP ARROW><UP ARROW><UP ARROW><ARROW UP><ARROW UP>

 

Turning to your earlier point about my own approach not working if the target folder is off screen, that's easily fixed by a single windows position command.

 

Apart from its relative simplicity, my approach covers all file types in any user's context menu, without your 'Other' step. In my case I was surprised that there are 18 options, although most I haven't used for years!

 

Folder
Shortcut
Microsoft Access Database
AutoHotkey Script
AviSynth Script
Bitmap image
Microsoft Word Document
Project Machinery
Microsoft Access Database
Microsoft PowerPoint Presentation
Microsoft Publisher Document
WinRAR archive
Rich Text Format
Text Document
Visio 2000 Drawing
X3D Document
Microsoft Excel Worksheet
WinRAR ZIP archive

 

Terry

Link to comment
Share on other sites

5 hours ago, terrypin said:

BTW, isn't it curious that our versions of MX Pro use different command text 🙂

 


  Text Type (Simulate Keystrokes): <UP ARROW><UP ARROW><UP ARROW><ARROW UP><ARROW UP>

 

Huh.  I had never noticed that before. I got curious so I did some testing.

 

Captured macros have:

Text Type (Simulate Keystrokes): <DOWN ARROW><LEFT ARROW><RIGHT ARROW><UP ARROW>

 

The Text Type command enters:

Text Type (Simulate Keystrokes): <ARROW DOWN><ARROW LEFT><ARROW RIGHT><ARROW UP>

 

Both forms work. Interesting.

Link to comment
Share on other sites

The typo is in a comment. I typed it, but didn't proofread it carefully. I never would have imagined that at the code level, <ARROW DOWN> and <DOWN ARROW> are equivalent.

 

Serendipitous learning is a "side-effect" of participating in this forum!

 

Quote

In my case I was surprised that there are 18 options, although most I haven't used for years!

 

I only regularly use three of the many options in the menu; the rest, never or rarely. The one I do need on occasion is new shortcut, so maybe I'll modify my script... or just leave it knowing that "Other" is available for those once-in-a-blue-moon situations.

Link to comment
Share on other sites

The solutions Terry and I proposed are similar: both use Macro Express to interact with the user interface of File Explorer. Terry's solution is mouse-centric, and mine is keyboard-centric.

 

I wonder whether adding a new folder or file could be accomplished in more programmatic ways:

 

Create Folder "%ExistingPath%\"
Copy File/Files: "c:\File Storage\New Word document.doc" to "%ExistingPath%\New Word document.doc"

 

The challenge I anticipate is that extracting the path of the current folder may not be straightforward due to peculiarities with File Explorer. But I think I'm going to try, anyways...

Link to comment
Share on other sites

Going slightly OT: I have a macro that occasionally saves me some tedious keying. It lets me add up to 99 new folders by specifying the total number, the starting number and the name, including optional separator.

 

I’ll post it if anyone wants.

Link to comment
Share on other sites

The macro is simple, no great challenge, and I’ll post it in the morning. Of course, you or anyone else could take advantage of the time zone gap and write one that does what I described before I post it!

 

And to be honest I already have a backlog of “must write” macros that’s enough of a challenge right now 🙂

Link to comment
Share on other sites

Here's my first go:

 

// Add up to 99 folders by specifying a path, name, start number, end number, and optional separator
 
// Try to remember previous values of variables. (But they won't survive a reboot!)
Variable Restore: Restore All Variables
 
// If the path is not already set, set a default path
If Variable %Path% Equals ""
  Variable Set String %Path% to "c:\Tmp\"
End If
 
// Ask for the path. New folders will be injected here
Variable Set String %Path%: Prompt
 
// Ensure path ends in a backslash
Variable Set Integer %PathLen% to the length of variable %Path%
Variable Modify String: Copy part of text in %Path% starting at %PathLen% and 1 characters long to %LastCharInPath%
If Variable %LastCharInPath% Does not Equal "\"
  Variable Set String %Path% to "%Path%\"
End If
 
// Ask for the folder name, separator, start number, and end number
Variable Set String %FolderName%: Prompt
Variable Set String %Separator%: Prompt
Variable Set Integer %StartCount%: Prompt
Variable Set Integer %EndCount%: Prompt
 
// Check for illegal separators
// NOT IMPLEMENTED YET: check for <>:"/\|?*
 
// Check for illegal paths, folder names, start numbers that are greater than the end numbers, etc.
// NOT IMPLEMENTED YET
 
// Limit how many folders the macro will create
Variable Modify Integer: %TotalFoldersToCreate% = %EndCount% - %StartCount%
If Variable %TotalFoldersToCreate% Is Greater Than or Equal To "99"
  MessageBox: %TotalFoldersToCreate% is too many!
  Macro Stop
End If
 
// Create folders!
Repeat Start (Repeat %EndCount% times)
  Create Folder "%Path%%FolderName%%Separator%%Count%"
End Repeat
Beep
 
// Save variable values. They won't survive a reboot!
Variable Save: Save All Variables

<COMMENT Value="Add up to 99 folders by specifying a path, name, start number, end number, and optional separator"/>
<COMMENT/>
<COMMENT Value="Try to remember previous values of variables. (But they won't survive a reboot!)"/>
<VARIABLE RESTORE Option="\x00"/>
<COMMENT/>
<COMMENT Value="If the path is not already set, set a default path"/>
<IF VARIABLE Variable="%Path%" Condition="\x00" IgnoreCase="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%Path%" Value="c:\\Tmp\\" NoEmbeddedVars="FALSE"/>
<END IF/>
<COMMENT/>
<COMMENT Value="Ask for the path. New folders will be injected here"/>
<VARIABLE SET STRING Option="\x01" Destination="%Path%" Prompt="Target Folder:" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
<COMMENT/>
<COMMENT Value="Ensure path ends in a backslash"/>
<VARIABLE SET INTEGER Option="\x0D" Destination="%PathLen%" Text_Variable="%Path%"/>
<VARIABLE MODIFY STRING Option="\x09" Destination="%LastCharInPath%" Variable="%Path%" Start="%PathLen%" Count="1" NoEmbeddedVars="FALSE"/>
<IF VARIABLE Variable="%LastCharInPath%" Condition="\x01" Value="\\" IgnoreCase="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%Path%" Value="%Path%\\" NoEmbeddedVars="FALSE"/>
<END IF/>
<COMMENT/>
<COMMENT Value="Ask for the folder name, separator, start number, and end number"/>
<VARIABLE SET STRING Option="\x01" Destination="%FolderName%" Prompt="What is the name of the folder?" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
<VARIABLE SET STRING Option="\x01" Destination="%Separator%" Prompt="Specify a separator (optional)" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
<VARIABLE SET INTEGER Option="\x01" Destination="%StartCount%" Prompt="Starting Count" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
<VARIABLE SET INTEGER Option="\x01" Destination="%EndCount%" Prompt="Last number of a created folder?" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
<COMMENT/>
<COMMENT Value="Check for illegal separators"/>
<COMMENT Value="NOT IMPLEMENTED YET: check for <>:\"/\\|?*"/>
<COMMENT/>
<COMMENT Value="Check for illegal paths, folder names, start numbers that are greater than the end numbers, etc."/>
<COMMENT Value="NOT IMPLEMENTED YET"/>
<COMMENT/>
<COMMENT Value="Limit how many folders the macro will create"/>
<VARIABLE MODIFY INTEGER Option="\x01" Destination="%TotalFoldersToCreate%" Value1="%EndCount%" Value2="%StartCount%"/>
<IF VARIABLE Variable="%TotalFoldersToCreate%" Condition="\x04" Value="99" IgnoreCase="FALSE"/>
<MESSAGEBOX Caption="%TotalFoldersToCreate% is too many!" Message="Maximum number of folders is 99!" Icon="4"/>
<MACRO STOP/>
<END IF/>
<COMMENT/>
<COMMENT Value="Create folders!"/>
<REPEAT START Start="%StartCount%" Step="1" Count="%EndCount%" Save="TRUE" Variable="%Count%"/>
<CREATE FOLDER Path="%Path%%FolderName%%Separator%%Count%"/>
<END REPEAT/>
<BEEP/>
<COMMENT/>
<COMMENT Value="Save variable values. They won't survive a reboot!"/>
<VARIABLE SAVE Option="\x00"/>

 

 

Link to comment
Share on other sites

Hi Alan,

 

That was quick! But perhaps you made it harder than necessary. I assumed that when I wanted to add subfolders I would always start with the parent folder active. So Alt+d immediately selects the path.


Also, my optional separator was just part of subfolder name. And I padded the suffix to ensure correct sorting.

 

// This should create a set of up to 99 new folders with names in form FolderName01, FolderName02, etc.
// Typically enter name 'Day' to get subfolders called Day01, Day02, etc in the current project folder.
Text Type (Simulate Keystrokes): <ALT>d
Clipboard Copy
Variable Set String %tParent% from the clipboard contents
Variable Set String %tFolderName%: Prompt
Variable Set Integer %nFolders%: Prompt
Variable Set Integer %nStart%: Prompt
Variable Set Integer %nCount% to 1
Repeat Start (Repeat %nFolders% times) // Repeat for every folder
  Variable Modify Integer %nCount%: Convert to Text String (%tCount%)
  If Variable %nCount% Is Less Than or Equal To "9" // Need to pad with a zero
    Variable Set String %tPad% to "0"
  Else
    Variable Set String %tPad% to ""
  End If
  Variable Modify String: Replace "%tCount%" in %tCount% with "%tPad%%tCount%"
  Create Folder "%tParent%\%tFolderName%%tCount%"
  Delay: 0.1 seconds
End Repeat

<COMMENT Value="This should create a set of up to 99 new folders with names in form FolderName01, FolderName02, etc."/>
<COMMENT Value="Typically enter name 'Day' to get subfolders called Day01, Day02, etc in the current project folder."/>
<TEXT TYPE Action="0" Text="<ALT>d"/>
<CLIPBOARD COPY/>
<VARIABLE SET STRING Option="\x02" Destination="%tParent%" NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x01" Destination="%tFolderName%" Prompt="Enter the folder name prefix, including any separator required." Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
<VARIABLE SET INTEGER Option="\x01" Destination="%nFolders%" Prompt="How many folders to create?" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
<VARIABLE SET INTEGER Option="\x01" Destination="%nStart%" Prompt="What should be the starting number?" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%nCount%" Value="1"/>
<REPEAT START Start="%nStart%" Step="1" Count="%nFolders%" Save="TRUE" Variable="%nCount%" _COMMENT="Repeat for every folder"/>
<VARIABLE MODIFY INTEGER Option="\x04" Destination="%nCount%" Variable="%tCount%"/>
<IF VARIABLE Variable="%nCount%" Condition="\x05" Value="9" IgnoreCase="FALSE" _COMMENT="Need to pad with a zero"/>
<VARIABLE SET STRING Option="\x00" Destination="%tPad%" Value="0" NoEmbeddedVars="FALSE"/>
<ELSE/>
<VARIABLE SET STRING Option="\x00" Destination="%tPad%" NoEmbeddedVars="FALSE"/>
<END IF/>
<VARIABLE MODIFY STRING Option="\x0F" Destination="%tCount%" ToReplace="%tCount%" ReplaceWith="%tPad%%tCount%" All="FALSE" IgnoreCase="FALSE" NoEmbeddedVars="FALSE"/>
<CREATE FOLDER Path="%tParent%\\%tFolderName%%tCount%"/>
<DELAY Flags="\x01" Time="0.1"/>
<END REPEAT/>
  

 

Terry

Link to comment
Share on other sites

Very nice, Terry. It makes sense to slap a zero to the front of 1 to 9!

 

I've had problems copying paths from the address bar in File Explorer. For most folders, the address bar, once selected, does show the path. But not always. Sometimes the field contains descriptive text such as "Documents," "This PC," and Pictures."

 

Here are images of the address bar, before and after selection, in my "Pictures" folder:

 

image.png.c9fc2582803913fd0a90bc245e741189.png

 

 

 

The path to this folder is "C:\Users\[my windows user]\Pictures" yet the address bar gives no clue.

 

There are only a handful of folders that have this address bar inconsistency, so it may not be an issue. 

 

 

Link to comment
Share on other sites

Yes, I get the same problem occasionally. I suppose I've been lucky so far in not using my macro in any of them. What prompted it was my video projects covering family holidays, because to maintain a semblance of order I would file resources for a fortnight's vacation in subfolders like Day01, Day02... Walk-01, Walk-02, etc.

 

EDITED 20 mins later:

I suppose the easiest solution would be to include a few IF commands, like IF name = Pictures then change name to ...

 

I haven't tried it but if you're keen you could consider the following advice from my archives. If you do so successfully, let me know and I'll hack it too.

--------------------

 

These special folders are called KnownFolders by the Windows Shell.

The mappings of the KnownFolders to the ParsingName are stored in the registry here:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\

The key names are the GUIDs for the KnownFolder, see below.

To make Explorer stop opening the KnownFolder rather than the opening drive path as a normal folder, change its ParsingName property by removing either the shell::: or :: from the beginning, but leaving the rest of it as-is.

So to change Downloads, open the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{374DE290-123F-4565-9164-39C4925E467B}

Change ParsingName from this:

shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{374DE290-123F-4565-9164-39C4925E467B}

to this:

{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{374DE290-123F-4565-9164-39C4925E467B}

You can also just delete the ParsingName property, but I don't recommend this since if you ever want to undo the change, you will have to find your backup. If you leave the GUID, you can just add shell::: or :: at the beginning. (They are interchangeable.)

For changes to take effect, you need to log out and back in or restart.

Here are GUIDs for some of the common folders:

User Profile Root (C:\Users\<username>\)
{f3ce0f7c-4901-4acc-8648-d5d44b04ef8f}

Contacts
{56784854-C6CB-462b-8169-88E350ACB882}

Desktop
{754AC886-DF64-4CBA-86B5-F7FBF4FBCEF5}

Downloads
{374DE290-123F-4565-9164-39C4925E467B}

Documents
{FDD39AD0-238F-46AF-ADB4-6C85480369C7}

Favorites
{1777F761-68AD-4D8A-87BD-30B759FA33DD}

Links
{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}

Pictures
{33E28130-4E1E-4676-835A-98395C3BC3BB}

Music
{4BD8D571-6D19-48D3-BE97-422220080E43}

OneDrive
{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}

Videos
{18989B1D-99B5-455B-841C-AB7C74E4DDFC}

For the full list, see the Microsoft Docs page:
https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid

--------------------

Terry

Link to comment
Share on other sites

Here is a workaround so that the script doesn't have to navigate to the Address bar get the path. No need to move the focus, so possibly it would run more reliably and faster:

 

In Windows File Explorer > View > Options > Change folder and search options > View, there is the option to "Display the full path in the title bar"

 

 

 

Once you've made this change, click "Apply to folders" and you'll be prompted whether you want the setting applied to all File Explorer windows. Answer "Yes."

 

Thereafter, the path will appear in the title bar -- except, unfortunately, for "KnownFolders."

 

 

 

So now the path can be retrieved programmatically, without messing with the keyboard or mouse:

 

  Variable Set String %Path% to topmost window title

 

Link to comment
Share on other sites

Yes, that’s a viable option and for a while that was the way I used to handle capturing paths. But i soon reverted. For me a condensed window title is far preferable overall. I wouldn’t mind betting that, if you switch to full path titles, some of your existing macros will fail. I even had a period when I used a macro to toggle between those options, but that proved impractical after a while.

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