How to run a temporary marked file with an external app?
-
Hi guys,
so normally when I do create new tabs and write my text into them I do not save them (orange marked line at tab top) and just keep them in backup mode (I do prefer). Now I did notice that I can not run those temp / backup files with any other external app using the “$(FULL_CURRENT_PATH)” command it does fail (file not found) or the external app starts just empty. I would like to know whether there is any method in Notepad++ to pipe the content of any selected tab into the external application? Or is there any way to tell npp to use the backup file of selected tab to send this into the external app?
Example: I have created a new tab 5 and did enter any text and a backup file of this tab / content was created into backup folder and this file npp should use now to load it into my desired app I want to run from npp Run menu etc. Otherwise I need to have some kind of temporary file / clipboard or similar you know what I mean? Is there anything I can do / setup in npp to make it work without to save the temporary tab as real file? Maybe like this…
"C:\...\external.exe" "$(FULL_CURRENT_PATH)" to "C:\...\external.exe" "$(TEMP_TAB)" or "C:\...\external.exe" "$(BACKUP_FILE)"
…or what about using one master file (current_saved_file) which gets created / stored directly into npp folder (fix place) and adding a new option called current_save etc and when the user does choose this option then the tab content gets saved into that file and the orange tab line gets changed to any other color and now the $(FULL_CURRENT_PATH) could use this file instead. Just a quick idea but maybe something like this would be good for all who working like me creating just temp / backup files instead of normal saved files. Workflow is faster & better without to save every tab each time. Mostly I work on different tabs at same time just in temp / back mode.
-
@Dean-Corso, for new tab 5 the variable $(FULL_CURRENT_PATH) contains the name “new 5” without a full path.
The backup file will have a name such as “new 1@2023-12-31_213241” but Notepad++ does not seem to have a way for you discover the path to that file. It’s not available as a variable like $(FULL_CURRENT_PATH)
Your workflow could get coded so that if it gets called with the name such as “new 5” without the full path that you scan for the most recent file that matches
%AppData\Notepad++\backup\new 5@yyyy-mm-dd_hhmmss
and hope that is the backup file.You could try a feature request asking for either that
$(FULL_CURRENT_PATH)
point to the backup file or that a new variable, such as$(FULL_BACKUP_PATH)
get added that points to the backup file. if there is one. Keep in mind that when editing a normal file that Notepad++ will erase the backup file when you doCtrl-S
orFile / Save
. If you then make any changes Notepad++ creates a new backup file using the current date/time for the@yyyy-mm-dd_hhmmss
part. Thus, retrievingFULL_BACKUP_PATH
was added to Notepad++ then it would be a rather volatile file.Having
$(FULL_CURRENT_PATH)
point to the backup file has some merit though one concern is that Notepad++ is not set up to allow for other applications to make changes to a backup file the way it currently detects/supports changes to a normal file by external applications. -
In general, it’s a bad idea. Now, you think it is a great idea, but I’ve been around Notepad++ for a long time, and, well, it’s not.
Temporary file tabs (e.g. “new 5”) are meant to be just that – temporary. Ideally, they exist only long enough to cross the threshold from an empty tab to a tab with some content of value. And at that point, you should save the file into the file system.
I’d suggest to you to try the TakeNotes plugin.
Here are a couple of FAQ entries that could be relevant:
- https://community.notepad-plus-plus.org/topic/21782/faq-periodic-backup-vs-autosave-plugin
- https://community.notepad-plus-plus.org/topic/15742/faq-autosaving-unnamed-new-1-files
FAQ entries often contain valuable wisdom from veteran users that have travelled the roads before you…
-
Hey guys,
ok I see it. Just working when using the direct full path manually of any backup file. No good idea to do that like this which makes the whole matter pretty static.
So I have to say that my temporary files do exists so long till I close them manually and they never got removed by npp itself etc. Always using portable versions of npp where the backup folder is stored into application folder itself instead of %AppData% when you have installed npp. I made tons of tabs over the years. So I think I don’t have to worry about that getting anything lost.
I think my idea is a good one to build any kind of temp save function for temporary tabs without to save them by the user itself. So for this you could also use the temp folder to store the content of current tab into an npp file. In this case the user would have the choice of normal save operation to save the content to file or to save the content of a temporary file in temporary file / container etc (snapshot of the tab content) and using it with any present or maybe newer variable command as I told before like $(FULL_CURRENT_TEMP_PATH). Anything like that you know. Now I could also run my current tab text content with any other external tools to verify it here & there without to save it by myself.
Maybe my idea does not sound good for you but I would like that idea to build anything like that specially in cases where user do work with many temporary tabs at the same time so then its pretty annoying to save every single tab separated also if you don’t need them later anymore when you finished and you got to delete them manually away. Some kind of more annoying detour.
The AutoSave Plugin only does save already saved files no temp / backup files. Not what I’m looking for.
So the idea I have is to got some kind of cache location npp could copy the tab content into and the user could also use this temporary filled cache with any external app $(CACHE) and that’s all so far. I think the idea makes just sense for people who working mostly in temporary mode + the need to run the “current content snapshot” in external apps.
-
Did you consider trying the TakeNotes plugin per my earlier suggestion?
I really do think it gets you 90% of what you’re seeking, without any of the difficulties or potential problems.IMO, the author of Notepad++ has carefully considered “temporary” files, and isn’t likely to change their functionality in order to support your idea. But you can always attempt to request it.
Good luck.
-
Yes I tries that plugin TakeNotes too but in this case I only can change my temp tab to a saved tab (save as note) what I don’t want or I can just create a new note tab and need to copy & paste the content of my temp tab into the note tab press save button and run it then with any external app I want. All in all it’s almost same like to save the file manually and just too much detour operations = no good & liquid running workflow for me. So to answer your question, the plugin is not what I’m looking for too, unfortunately. But otherwise it’s OK when I just work with those note files (when I need it) to save them directly into a custom folder. Maybe not the best solution but better than nothing. Thanks again for that tip Alan.