DonationCoder.com Forum

Main Area and Open Discussion => General Software Discussion => Topic started by: bardman on October 27, 2018, 11:52 PM

Title: Rename Open File in Windows
Post by: bardman on October 27, 2018, 11:52 PM
I download many training documents in PDF format in Windows. Unfortunately, many of the file names are generic or truncated so the corresponding file is hard to identify by those titles.

Can someone please code an app that renames files (primarily PDFs) while that PDF file is open for the Windows operating system?

Thanks in advance.
Title: Re: Rename Open File in Windows
Post by: wraith808 on October 28, 2018, 01:27 AM
I download many training documents in PDF format in Windows. Unfortunately, many of the file names are generic or truncated so the corresponding file is hard to identify by those titles.

Can someone please code an app that renames files (primarily PDFs) while that PDF file is open for the Windows operating system?

Thanks in advance.

The problem is the fact that the PDF application has a handle on the file while it is open.  In that case, nothing can rename it without the file being closed first.  You'd have to have a PDF application that streamed it all into a temporary file or memory and then released the file in order to make that work.  And in that case, Windows would allow it to be renamed without a special program to do so.
Title: Re: Rename Open File in Windows
Post by: KodeZwerg on October 28, 2018, 01:40 AM
Well, two problems and two solutions.
Two Problems:
1st: how should my Application know wich file you want to rename?
2nd: has mentioned wraith808, open files cannot be renamed.

Solution 1: if i know how to solve 1st problem: use a copy command instead of file move.
Collect names that you renamed into a list.
Set this list to be deleted on a buttonpress or on next OS reboot.

Solution 2: I could write a Pdf Viewer wich let me set Filename. (needs a bit longer to code)

Question: Interested in one of my Ideas?
Title: Re: Rename Open File in Windows
Post by: Curt on October 28, 2018, 02:56 AM
so what is IrfanView doing when (on my command) it renames an open picture file?
 :-\
Title: Re: Rename Open File in Windows
Post by: KodeZwerg on October 28, 2018, 03:11 AM
so what is IrfanView doing when (on my command) it renames an open picture file?
 :-\
Open picture with Windows Paint or similar, than try rename with any tool/Explorer = access denied. (copy works)
Title: Re: Rename Open File in Windows
Post by: tomos on October 28, 2018, 06:33 AM
Good question though -- what exactly is IrfanView doing (didnt even know it had that capablity).

If I'm downloading a PDF I will open it directly, rather than save, and then Crtl+Shift+S will allow me to save it with new and/or modified name.
Software tends to remember where you last saved and go directly there, which is mostly convenient. (I use Adobe Reader as PDF viewer.)
Depending on your browser, opening directly can be made the default behaviour (in Pale Moon here, clicking a PDF link will open the Open/Save dialogue with 'Open with' selected by default, I just have to press return).

As I say, a workaround, throwing it out there as it might meet OP requirements.
Title: Re: Rename Open File in Windows
Post by: bardman on October 28, 2018, 06:43 AM
Yeah. I can do a 'Save As' in Adobe Acrobat and the rename is no issue. Apparently, the 'Save As' obviously does not have a restriction for renaming an open file in contrast to just renaming the file via right-click.
Title: Re: Rename Open File in Windows
Post by: bardman on October 28, 2018, 07:04 AM
Well, two problems and two solutions.
Two Problems:
1st: how should my Application know wich file you want to rename?
2nd: has mentioned wraith808, open files cannot be renamed.
 
Solution 1: if i know how to solve 1st problem: use a copy command instead of file move.
Collect names that you renamed into a list.
Set this list to be deleted on a buttonpress or on next OS reboot.

Solution 2: I could write a Pdf Viewer which let me set Filename. (needs a bit longer to code)

Question: Interested in one of my Ideas?

Howdy KodeZwerg,

I wasn't actually expecting a response until 2019?

But problem 1 could be a drag and drop or browse to the particular file. That copy command works beautifully, yes even with the file open via command line or direct copying! Of course, now I am doing more than needs to be done just to rename it. I open the file to obtain the actual name of the document.

I think a quick and dirty app is all that is needed as opposed Solution 2.

So general workflow:
1. Open PDF file in Adobe Acrobat (of course other PDF viewers are options)
2. Most times I copy the general title of the file from the text within the file
3. Drag and Drop the file or browse to select it in the Rename Open File app
4. Have the option to type in or paste in the copied title
5. Instant billionaire for such a useful and simple Windows app

Thank you
 
Title: Re: Rename Open File in Windows
Post by: skwire on October 28, 2018, 08:24 AM
Yeah. I can do a 'Save As' in Adobe Acrobat and the rename is no issue. Apparently, the 'Save As' obviously does not have a restriction for renaming an open file in contrast to just renaming the file via right-click.

A "Save as..." operation creates a copy of the open file, i.e., it doesn't rename the original, open file.

You'd have to have a PDF application that streamed it all into a temporary file or memory and then released the file in order to make that work.  And in that case, Windows would allow it to be renamed without a special program to do so.

SumatraPDF (https://www.sumatrapdfreader.org/free-pdf-reader.html) allows for this and also has a "Rename" option within its own file menu or by pressing F2.  If you choose this option and rename a file, SumatraPDF will rename it and then re-open the PDF with the new filename.  In fact, if you open a PDF file in SumatraPDF and then rename it outside of SumatraPDF, it detects this and its internal "Rename" menu entry becomes greyed out.  At that point, you have to use the "Save As..." option.  FWIW, I use the rename feature all the time for the same reasons as the original poster.

@bardman:  Rather than creating an app for this, is it possible for you to just switch to using SumatraPDF (https://www.sumatrapdfreader.org/free-pdf-reader.html)?
Title: Re: Rename Open File in Windows
Post by: tomos on October 28, 2018, 08:51 AM
Yeah. I can do a 'Save As' in Adobe Acrobat and the rename is no issue. Apparently, the 'Save As' obviously does not have a restriction for renaming an open file in contrast to just renaming the file via right-click.

yes, but note (as Skwire says above) it creates a copy -- if you have downloaded it directly to e.g. Adobe Acrobat, the original is in the Temp folder, your 'save as' will save a copy of that wherever you choose.
This (and/or the Sumatra solution in Skwire's post above) seems to make an app unnecessary (?)
Title: Re: Rename Open File in Windows
Post by: wraith808 on October 28, 2018, 09:49 AM
so what is IrfanView doing when (on my command) it renames an open picture file?
 :-\


Its closing the file that it has a lock on, renaming it, and re-opening it.  Or its streaming the whole thing into memory, closing the lock, and then reopening it.  It's not impossible, as I say.  It's just based more on the fact that he wants it to rename a file that something else has a lock on.  I can create a quick test app that would prevent anything from renaming that image file- even irfanview.  :-\

SumatraPDF allows for this and also has a "Rename" option within its own file menu or by pressing F2.  If you choose this option and rename a file, SumatraPDF will rename it and then re-open the PDF with the new filename.  In fact, if you open a PDF file in SumatraPDF and then rename it outside of SumatraPDF, it detects this and its internal "Rename" menu entry becomes greyed out.  At that point, you have to use the "Save As..." option.  FWIW, I use the rename feature all the time for the same reasons as the original poster.

Yup.  And as I said, that's on the PDF reader :)  Thanks for pointing that one out!  I'd forgotten that SumatraPDF did this exact thing!
Title: Re: Rename Open File in Windows
Post by: bardman on October 28, 2018, 01:13 PM
Shoot, so I have just been using the wrong app the whole time! Sumatra will now be employed when renaming my PDFs. Thanks, everyone.

Maybe Adobe and some other apps should employ a rename in the same manner as Sumatra.
Title: Re: Rename Open File in Windows
Post by: skwire on October 28, 2018, 02:09 PM
Shoot, so I have just been using the wrong app the whole time! Sumatra will now be employed when renaming my PDFs. Thanks, everyone.

SumatraPDF is great, and I use it for 99% of my PDF reading needs.  For the rare, problematic PDFs that Sumatra won't render, and for minor editing, I keep an older PDF-Xchange Viewer installed.
Title: Re: Rename Open File in Windows
Post by: Curt on October 28, 2018, 03:45 PM
The answers made me slowly remember to install GhostScript; Now my IrfanView can also rename an open pdf file. Thank you!
Title: Re: Rename Open File in Windows
Post by: KodeZwerg on October 28, 2018, 05:30 PM
From my side, FoxIt Pdf runs fast like hell and offer renaming features (optional "Save as..." copy).
Aslong you do not need to edit those Pdf's, FoxIt would be my #1 for free.
Just for fun i might come up with an easy Pdf-Viewer/Renamer Tools.... let's see :-)
Title: Re: Rename Open File in Windows
Post by: bardman on October 28, 2018, 10:39 PM
I just saved a Notepad file and a WinRAR zip while it was open without any issues. Apparently, this is app related more than anything else. Some of MS's Office suite products have this restriction as well.
Title: Re: Rename Open File in Windows
Post by: tomos on October 29, 2018, 02:59 AM
I just saved a Notepad file and a WinRAR zip while it was open without any issues. Apparently, this is app related more than anything else. Some of MS's Office suite products have this restriction as well.
Do you mean you did a "save as" ?
Title: Re: Rename Open File in Windows
Post by: wraith808 on October 29, 2018, 01:02 PM
I just saved a Notepad file and a WinRAR zip while it was open without any issues. Apparently, this is app related more than anything else. Some of MS's Office suite products have this restriction as well.

Some applications take the whole file into memory, thus releasing the handle on the file.  I didn't think Notepad was one of those, but checking, apparently it is.  If you'll notice, however- if you save the file loaded into notepad at that point, it creates an additional file with that name.

For my test, I created a file test.txt and opened it in notepad.  It had one line in it.  I then renamed it test1.txt.  I updated the file open in notepad, then saved it.  The newly created test.txt had my updates.  The text1.txt did not- it had the original text.
Title: Re: Rename Open File in Windows
Post by: Lintalist on October 29, 2018, 02:43 PM
My alternative: I use Total Commander - a shareware dual pane file manager - but there are freeware version clones (double commander, multi commander and many more) - These type of filemanagers have a "quick view" option (example https://www.ghisler.com/screenshots/en/02.html ) that will show the PDF (in this case) in the opposite panel - in the active panel you can now easily rename the PDF (other files) based on what you see - depending on the PDF you could even select text from the "viewing panel" and use that to rename your file.

Now you will often need to do something extra to get PDF viewing to work by installing a plugin (very easy to do) but there are many viewers for many different filetypes. (Quick)  Viewing won't lock the files and you can easily rename them.
Title: Re: Rename Open File in Windows
Post by: xtabber on October 30, 2018, 09:06 AM
XYplorer's built-in file viewer displays pdf files properly and does not lock the file being viewed, so you can rename it while viewing it.

The viewer, which can be shown in a pane or a separate movable window, always displays whatever file is currently selected, so you can simply scroll down through a list of files and rename them on the fly, without ever having to open them in a separate program.
Title: Re: Rename Open File in Windows
Post by: Stoic Joker on October 30, 2018, 02:01 PM
SumatraPDF is great, and I use it for 99% of my PDF reading needs.

Damn, that thing is fast. I've been using PDF-Xchange … But I think I might of just switched!
Title: Re: Rename Open File in Windows
Post by: wraith808 on October 30, 2018, 06:01 PM
XYplorer's built-in file viewer displays pdf files properly and does not lock the file being viewed, so you can rename it while viewing it.

That's not a true view though if you're talking about what I think you're talking about.  It's just a preview. (Unless I'm totally missing out on a feature)
Title: Re: Rename Open File in Windows
Post by: KodeZwerg on October 31, 2018, 02:03 AM
A preview aint a view?  ;D
Title: Re: Rename Open File in Windows
Post by: bardman on October 31, 2018, 10:15 AM
I just saved a Notepad file and a WinRAR zip while it was open without any issues. Apparently, this is app related more than anything else. Some of MS's Office suite products have this restriction as well.
Do you mean you did a "save as" ?

Nope!. While the file was open, I right-clicked the name of it and renamed it successfully and the file I was viewing, name changed too.
Title: Re: Rename Open File in Windows
Post by: Lintalist on October 31, 2018, 01:20 PM
Just fyi TC's Quick View can be opened in a separate Lister* window, which updates contents when going to other file. And the plugin that will show the PDF uses SumatraPDF which you can simply update by copied SumatraPDF.exe to the lister plugin folder (so you don't  have to rely on the plugin developer to keep "PDF viewing" op to date.

* Lister is name of the file viewer component of TC which is also used in regular Quick View panel.
Title: Re: Rename Open File in Windows
Post by: wraith808 on October 31, 2018, 09:44 PM
A preview aint a view?  ;D

No.  It's just a preview of the cover of it.