Handy use for Paper Folders with Long Paths via Powershell

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Dustydog
Posts: 321
Joined: 13 Jun 2016 04:19

Handy use for Paper Folders with Long Paths via Powershell

Post by Dustydog »

Attribution for the very elegant Powershell solution goes to Rani Khier from: http://stackoverflow.com/questions/1269 ... in-windows

I paste this Powershell single-line script into a text file in my root directories for easy cut-paste access from any computer. (I also keep a snippets file, but I use this enough that it's convenient.):

Code: Select all

Out-File paper_XY_longfilepath.txt ; cmd /c "dir /b /s /a" | ForEach-Object { if ($_.length -gt 250) {$_ | Out-File -append paper_XY_longfilepath.txt}}
This creates a list of full pathnames for files with length greater than 250 in paper_XY_longfilepath.txt in the directory from which you ran the Powershell command. (Obviously, it's trivial to change the "250" in the code.)

You may not want to run this from C:\ (or wherever else you have long system folders). If you do, you'll need to run Powershell as an administrator to avoid errors; this does recurse all subdirectories.

I prepared by putting the paper folder icon on my customize->toolbar. I also like having a column that shows "Len".

  • Open Powershell (elevated as required) from the directory you want to check; paste the snippet into the window and run it. It's very fast.

    Copy the resulting .txt file to <XYPLORER>\Paper\

    Hit the Paper Airplane icon to open "paper_XY_longfilepath.txt" as a paper folder.

    Enjoy XY's ability to manage long paths and arbitrary file locations gracefully.

If you want to run the command from multiple locations, simply rename the resulting .txt files before move, or cut and paste the results into the first file.

You may or may not wish to edit the resulting file before opening as a paper folder, especially if there are system files or the length has gotten silly. (I like EditPad Lite because of its excellent regex and full line support. I also use "Everything" if I've used this in several locations, before renaming and moving en masse to the paper folder.)

Dustydog
Posts: 321
Joined: 13 Jun 2016 04:19

Reminder of Long File Name Support Quoted from XY Help

Post by Dustydog »

This is just a quote from the help system regarding XY's support of Long File Names:
Support overlong filenames

--->Tick it to support filenames with more than 260 characters.<---


Background: In NTFS, the total length can be up to 32,765 characters with each component limited to 254 characters. The Windows Shell, however, doesn't allow overlong filenames (> 260 characters, including the terminating null character) and Shell functions (e.g. Copying, Moving, Deleting) will fail with items having overlong filenames. However, since it is possible to create items with overlong filenames under NTFS, with Explorer you are stuck when meeting such item: You cannot delete, rename, or move it! Consequently, also XYplorer will fail wherever it uses Shell functions. When Support overlong filenames is enabled, however, XYplorer will resort to Kernel functions that can deal with overlong filenames and thus work around the Shell limitations.

Note: XYplorer reports the filename length without the invisible terminating null character, but the maximum filename length for the windows shell is defined as 260 *including* the terminating null character. Therefore a filename reported as 260 characters by XYplorer is actually 261 characters for the shell and hence too long.

Here is a list of features with support for overlong filenames in XYplorer:

· Browse and search folders.

· Auto-refresh.

· Calculating the folder size.

· Create new files and folders within folders with overlong names.

· Inline Rename (Tree and List).

· Drag and drop overlong files, and cut/copy/paste them via clipboard. Note that the move/copy/delete support for overlong filenames is limited to operations on single items. Note also that the clipboard (tested on XP) will not handle items > 1027 characters.

· Image preview and thumbnails.

· Properties (Info Panel).

· Raw View (Info Panel).

· readfile, writefile (Scripting commands).

· Quick File View, Preview Tab, Preview Pane, Floating Preview, Full Screen Preview.

· Rename Special (menu File).

· Swap Names (menu File).

· Delete: If at least one of the items selected for deletion has an overlong filename you are automatically prompted to perform a special delete operation for such overlong items. Note that these deletions are permanent, they don't go to the Recycle Bin (it doesn't support overlong filenames).
Note that the automatic detection only scans the selected items, not any contained items (in selected folders). If only contained items are overlong, the automatic detection will not see them and the deletion will fail (shell error message). In that case use the command Delete Long from menu File to successfully delete the items in question.

· All "Copy Here..." commands (menu File), but only for files, not for folders.

· All Backup operations: Note that Backup Operations are not affected by the setting of Support overlong filenames! They always support overlong filenames.

admin
Site Admin
Posts: 66678
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Handy use for Paper Folders with Long Paths via Powershe

Post by admin »

FYI, XYplorer can find all long paths natively:

Code: Select all

len: > 259

Dustydog
Posts: 321
Joined: 13 Jun 2016 04:19

Re: Handy use for Paper Folders with Long Paths via Powershe

Post by Dustydog »

admin wrote:FYI, XYplorer can find all long paths natively:

Code: Select all

len: > 259
Lol, of course it can. Gads. But I'm still stuck knowing how to use other tools more thoroughly, even if it's just something I should have thought of that didn't occur to me. So when I come up with something like this, I at least feel happy for a few minutes. Before XY, I used the Powershell thing, so that's what I went back to, then I thought, "Cool! A paper folder!". I do like having the results in a paper folder though, as it becomes kind of a to-do list for file management that sticks around. You can see what you're getting into before opening the result, which is almost instant, and you can get some idea simply from the size of the resultant file. You can also edit it to leave only the ones you want to have stick around for future work even before opening.

I keep thinking of new ways to use your paper folders...any list of files I can make, with anything, suddenly becomes easily accessible - including "Everything" results. It's wonderful. And it suits my skill set.

(I think I'm just trying to justify myself for being daft.)

admin
Site Admin
Posts: 66678
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Handy use for Paper Folders with Long Paths via Powershe

Post by admin »

It's okay. Paper Folders are really totally delicious. I could sit on them. :beer:

Post Reply