rename using a text editor
rename using a text editor
is it possible to create a script with the following functionality?:
when files or/and folders are selected, load of the script leads to opening of a predefined text editor like notepad with titles of all selected items
after necessary rename actions are performed, this temporary notepad file is manually saved and closed and after that changes are automatically applied in xyplorer
the idea is borrowed from the great and simple app called 'free name':
sourceforge.net/projects/freename/files/freename/0.1
but i think that in xyplorer it can be done even more fine and fast
i saw this very old topic with related discussion:
xyplorer.com/xyfc/viewtopic.php?f=5&t=5313&start=15&sid=501782f409726bb862cfc814beb8c946
but i haven't found a solution there
when files or/and folders are selected, load of the script leads to opening of a predefined text editor like notepad with titles of all selected items
after necessary rename actions are performed, this temporary notepad file is manually saved and closed and after that changes are automatically applied in xyplorer
the idea is borrowed from the great and simple app called 'free name':
sourceforge.net/projects/freename/files/freename/0.1
but i think that in xyplorer it can be done even more fine and fast
i saw this very old topic with related discussion:
xyplorer.com/xyfc/viewtopic.php?f=5&t=5313&start=15&sid=501782f409726bb862cfc814beb8c946
but i haven't found a solution there
Re: rename using a text editor
One of my scripts helped you out? Please donate via Paypal
Re: rename using a text editor
highend, thanks. everything works in my xyplorer version 14.1
this script makes editing easier. unfortunately there are some inconveniences including the following:
1. necessity of extra-clicks. could be removed by implementing of a corresponding 'rename in external text editor' option directly into xyplorer code but i don't know if such plans exist
2. in my case the content of both windows (xyplorer's 'edit item names' and ColumnEdit.txt) usually does not look like easy to edit:
- at least because paths are not visible in any way. it may be important if list is big and if there are many similar or even same titles
- a situation gets worse due to the fact that main xyplorer's window (the only place to view/check those paths) is blocked by the 'edit item names' window.
only slow wheel-scrolling is possible (quick scrolling by holding left mouse button is not possible) but it is not convenient if the navigation panel contains many hundreds/thousands items
this script makes editing easier. unfortunately there are some inconveniences including the following:
1. necessity of extra-clicks. could be removed by implementing of a corresponding 'rename in external text editor' option directly into xyplorer code but i don't know if such plans exist
2. in my case the content of both windows (xyplorer's 'edit item names' and ColumnEdit.txt) usually does not look like easy to edit:
- at least because paths are not visible in any way. it may be important if list is big and if there are many similar or even same titles
- a situation gets worse due to the fact that main xyplorer's window (the only place to view/check those paths) is blocked by the 'edit item names' window.
only slow wheel-scrolling is possible (quick scrolling by holding left mouse button is not possible) but it is not convenient if the navigation panel contains many hundreds/thousands items
Re: rename using a text editor
1. Mh, you can always bind the xys script to a keyboard shortcut, a button, catalog item, etc.
I don't think that such a context menu item will be added to XY in the future
2. I see
The procedure could be done in a different way (even with displaying paths) and in a non-blocking
way but that would require a lot more effort for the external tool because it would need to take
care to show a difference window itself...
I don't think that such a context menu item will be added to XY in the future
2. I see
The procedure could be done in a different way (even with displaying paths) and in a non-blocking
way but that would require a lot more effort for the external tool because it would need to take
care to show a difference window itself...
One of my scripts helped you out? Please donate via Paypal
Re: rename using a text editor
highend, how can i alter the script so that the content of the ColumnEdit.txt was displayed with a level-indent?
in my case: 64 pixels for all files
just like i see folders and files in the branch view
for me this is the very important question because such improvement would have solved the 'paths' issue completely
in my case: 64 pixels for all files
just like i see folders and files in the branch view
for me this is the very important question because such improvement would have solved the 'paths' issue completely
Re: rename using a text editor
There are no "pixel" as indention, only spaces / tabs
Something like this should work:
Something like this should work:
Code: Select all
$spacePerLevel = 4;
// ========================================================================
// == DO NOT CHANGE ANYTHING BELOW IF YOU DO NOT KNOW WHAT YOU ARE DOING ==
// ========================================================================
$rootIndention = gettoken(<curpath>, "count", "\") + 1;
$indented = "";
foreach($item, <get SelectedItemsPathNames <crlf>>, <crlf>, "e") {
$curIndention = gettoken($item, "count", "\") - $rootIndention;
$indented = $indented . strrepeat(" ", $curIndention * $spacePerLevel) . gpc($item, "file") . <crlf>;
}
copytext $indented;
writefile("%TEMP%\~ColumnEdit.txt", $indented, , "utf8bom");
run "D:\Tools\AutoHotkey\@Scripts\ColumnEdit\ColumnEdit.exe", "%TEMP%";
sendkeys "^a^v";
#147;
One of my scripts helped you out? Please donate via Paypal
Re: rename using a text editor
the result is not good:
while it should look like:
you can also see that an unwanted empty line appeared in the bottom of the ColumnEdit.txt
Code: Select all
gpc(C:\WINDOWS\Temp\del3\del1, "file")
gpc(C:\WINDOWS\Temp\del3\del1\del1.txt, "file")
gpc(C:\WINDOWS\Temp\del3\del1\del2.txt, "file")
gpc(C:\WINDOWS\Temp\del3\del1\del3.txt, "file")
gpc(C:\WINDOWS\Temp\del3\del2, "file")
Code: Select all
del1
del1.txt
del2.txt
del3.txt
del2
Re: rename using a text editor
Your ancient version doesn't know about gpc as the abbreviation for getpathcomponent, so...
Code: Select all
$spacePerLevel = 4;
// ========================================================================
// == DO NOT CHANGE ANYTHING BELOW IF YOU DO NOT KNOW WHAT YOU ARE DOING ==
// ========================================================================
$rootIndention = gettoken(<curpath>, "count", "\") + 1;
$indented = "";
foreach($item, <get SelectedItemsPathNames <crlf>>, <crlf>, "e") {
$curIndention = gettoken($item, "count", "\") - $rootIndention;
$indented = $indented . strrepeat(" ", $curIndention * $spacePerLevel) . getpathcomponent($item, "file") . <crlf>;
}
copytext trim($indented, <crlf>, "R");
writefile("%TEMP%\~ColumnEdit.txt", $indented, , "utf8bom");
run "D:\Tools\AutoHotkey\@Scripts\ColumnEdit\ColumnEdit.exe", "%TEMP%";
sendkeys "^a^v";
#147;
One of my scripts helped you out? Please donate via Paypal
Re: rename using a text editor
now it works, thank you. i really appreciate your help
1. there are several more or less tangible problems at the moment:
a. after ColumnEdit.txt was edited and saved, it loses the focus immediately ('edit item names' window gets this focus automatically)
which makes no sense and is not convenient because now it is impossible to close ColumnEdit.txt via keyboard
which leads to more unnecessary clicks/button pressings since ColumnEdit.txt should be closed anyway
b. unwanted empty line (in the bottom of the ColumnEdit.txt) which was absent in the 1st version of the script
c. ColumnEdit.exe stays in processes if ColumnEdit.txt and 'edit item names' were closed without editing (in this case ColumnEdit.exe stays even after closing of xyplorer)
2. there is a question concerning this error: 'The system cannot find the path specified'
sometimes it is quite easy to get distracted and edit several titles (some folder and some file inside of it) in branch view
on attempt to rename them xyplorer shows the error related to the file (the folder is renamed without errors)
as i understand xyplorer tries to rename the folder at first. but why folder and not file?
3. version is ancient because there are reasons for it
for example this change which was compulsory implemented in march of 2015: No more Branch View on startup. It's blocked now
1. there are several more or less tangible problems at the moment:
a. after ColumnEdit.txt was edited and saved, it loses the focus immediately ('edit item names' window gets this focus automatically)
which makes no sense and is not convenient because now it is impossible to close ColumnEdit.txt via keyboard
which leads to more unnecessary clicks/button pressings since ColumnEdit.txt should be closed anyway
b. unwanted empty line (in the bottom of the ColumnEdit.txt) which was absent in the 1st version of the script
c. ColumnEdit.exe stays in processes if ColumnEdit.txt and 'edit item names' were closed without editing (in this case ColumnEdit.exe stays even after closing of xyplorer)
2. there is a question concerning this error: 'The system cannot find the path specified'
sometimes it is quite easy to get distracted and edit several titles (some folder and some file inside of it) in branch view
on attempt to rename them xyplorer shows the error related to the file (the folder is renamed without errors)
as i understand xyplorer tries to rename the folder at first. but why folder and not file?
3. version is ancient because there are reasons for it
for example this change which was compulsory implemented in march of 2015: No more Branch View on startup. It's blocked now
Re: rename using a text editor
1a. It makes sense because I edit the file in Sublime Text and when I'm done I close the file
(Sublime Text asks if I want to save it - YES) -> Focus is where I want it, in XY's window...
There is a newer version of the tool here: viewtopic.php?f=7&t=18752
There you can change this behavior by setting ActivateEditItemNamesWindow to 0 in the .ini file
1b. Ofc it doesn't exist in the original script, there was no foreach loop...
Replace
with these two lines
to change this...
1c. Changed in the new version. If the Edit Item Names... window from XYplorer is closed, ColumnEdit.exe will quit itself now...
2. Because it doesn't know / check if you are trying to rename a file or folder there -> Hence the error when you try to do both at the same time
3. It was blocked for a reason: Startup time
(Sublime Text asks if I want to save it - YES) -> Focus is where I want it, in XY's window...
There is a newer version of the tool here: viewtopic.php?f=7&t=18752
There you can change this behavior by setting ActivateEditItemNamesWindow to 0 in the .ini file
1b. Ofc it doesn't exist in the original script, there was no foreach loop...
Replace
Code: Select all
copytext trim($indented, <crlf>, "R");
Code: Select all
$indented = trim($indented, <crlf>, "R");
copytext $indented;
1c. Changed in the new version. If the Edit Item Names... window from XYplorer is closed, ColumnEdit.exe will quit itself now...
2. Because it doesn't know / check if you are trying to rename a file or folder there -> Hence the error when you try to do both at the same time
3. It was blocked for a reason: Startup time
One of my scripts helped you out? Please donate via Paypal
Re: rename using a text editor
1. how should i join the script for the newer version of the tool with old script? (that contains the 'indention' feature)
2. it seems that use of your script makes the visual appearance of the 'edit item names' window not only useless but also underfoot (at least for me)
is this new idea realizable?:
a. after load of the script: the 'edit item names' window is not visible at all
b. [preferably but not necessarily]
while editing the ColumnEdit.txt, xyplorer's main window is not blocked
c. after closing of ColumnEdit.txt:
- invisible 'edit item names' window gets the 'ctrl+enter' command automatically
- visible 'rename preview' window immediately appears
2. it seems that use of your script makes the visual appearance of the 'edit item names' window not only useless but also underfoot (at least for me)
is this new idea realizable?:
a. after load of the script: the 'edit item names' window is not visible at all
b. [preferably but not necessarily]
while editing the ColumnEdit.txt, xyplorer's main window is not blocked
c. after closing of ColumnEdit.txt:
- invisible 'edit item names' window gets the 'ctrl+enter' command automatically
- visible 'rename preview' window immediately appears
Re: rename using a text editor
1. Use the old script, not the one from the new thread
2. With this tool it's necessary to show the edit item names window.
Underfoot? No clue what this means...
a., b., c.:
Let me quote myself:
provides, e.g. the preview option, all of its flag parameters, etc.)
I will eventually do it, if this feature wish is implemented: viewtopic.php?f=5&t=18746
2. With this tool it's necessary to show the edit item names window.
Underfoot? No clue what this means...
a., b., c.:
Let me quote myself:
In other words: I will not reinvent the wheel (reprogramming everthing that the script command renameThe procedure could be done in a different way (even with displaying paths) and in a non-blocking
way but that would require a lot more effort for the external tool because it would need to take
care to show a difference window itself...
provides, e.g. the preview option, all of its flag parameters, etc.)
I will eventually do it, if this feature wish is implemented: viewtopic.php?f=5&t=18746
One of my scripts helped you out? Please donate via Paypal
Re: rename using a text editor
speaking about 2 versions of the script: 1) from the new thread 2) from this thread (script with the 'indention' feature)
the 1st script displays ColumnEdit.txt and its content immediately
the 2nd script is much slower in difficult cases. examples:
750 items (folders and files in branch view): script works immediately
7000 items: 7 seconds before ColumnEdit.txt appears
14000 items: 32 seconds
27000 items: 111 seconds (here and previously xyplorer does not display a red 'huge list' note)
36000 items: ~300 seconds (xyplorer displays a red 'huge list' note)
is there something that can be improved so that the speed was faster?
the 1st script displays ColumnEdit.txt and its content immediately
the 2nd script is much slower in difficult cases. examples:
750 items (folders and files in branch view): script works immediately
7000 items: 7 seconds before ColumnEdit.txt appears
14000 items: 32 seconds
27000 items: 111 seconds (here and previously xyplorer does not display a red 'huge list' note)
36000 items: ~300 seconds (xyplorer displays a red 'huge list' note)
is there something that can be improved so that the speed was faster?
Re: rename using a text editor
You could use something like this:
You would edit them with full paths in your editor...
Apart from that: To use the indented way you'd need to write an additional wrapper (even AHK isn't the fastest)
that does the foreach for all files (or has a regex engine that allows to replace match counts with <something different>)...
Code: Select all
if !(get("CountSelected")) { status "No item(s) selected, aborted!", "8B4513", "stop"; end true; }
writefile("%TEMP%\~ColumnEdit.txt", <get SelectedItemsPathNames <crlf>>, , "utf8bom");
run "D:\Tools\AutoHotkey\@Scripts\ColumnEdit\ColumnEdit.exe", "%TEMP%";
sendkeys "^a^v";
#147;
Apart from that: To use the indented way you'd need to write an additional wrapper (even AHK isn't the fastest)
that does the foreach for all files (or has a regex engine that allows to replace match counts with <something different>)...
One of my scripts helped you out? Please donate via Paypal
Re: rename using a text editor
this code is definitely not what i need
seemingly i will have to tolerate such speeds because there is no way i forget about this huge conveniency of the indented way
anyway this thread turned out to be a substantial help. and i'm grateful for that
still it's kind of strange to me that 7000 items are processed almost instantly while 27000 items demand so much time during which xyplorer is available for nothing
seemingly i will have to tolerate such speeds because there is no way i forget about this huge conveniency of the indented way
anyway this thread turned out to be a substantial help. and i'm grateful for that
still it's kind of strange to me that 7000 items are processed almost instantly while 27000 items demand so much time during which xyplorer is available for nothing