topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday December 14, 2024, 7:39 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Files 2 folder on steroids.  (Read 5587 times)

magician62

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 180
    • View Profile
    • Donate to Member
Files 2 folder on steroids.
« on: July 13, 2024, 06:04 AM »
I am finding I have a regular task, that would benefit from an easier way.

I have a folder with a various number of PDF's

I need to create  TXT files for each PDF with the same filename, and inside the TXT file write the filename less the file type.

I then need to move the PDF and associated TXT file into a folder of the same name.

At present I am manually creating the text file and adding the content, then using Files 2 Folders to folderise all the TXT files and finally manually drop the PDF's into the corresponding folder.

Preferably the Util will be in AHK as I want to learn how it is working so I can extrapolate for the future.

TIA.
Why an I Magician62? Because Magician1 thru 61 were gone. :)

paradisusvic

  • Participant
  • Joined in 2024
  • *
  • Posts: 73
  • Call me Vic!
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Files 2 folder on steroids.
« Reply #1 on: July 13, 2024, 08:42 AM »
Hello & good day!

I need to create  TXT files for each PDF with the same filename, and inside the TXT file write the filename less the file type.

Which PDF2TXT tool are you using for the conversion? If possible, show the actual command you are using :)

(Some tools have OCR settings, etc.)
My name's Victor but do feel free to call me Vic!

❤️ Support on Patreon @ www.patreon.com/paradisusio

GitHub: github.com/paradisusio

🌟 Good projects deserve support 🌎🌍🌏

✉ Email / Extend your PayPal support ❤️: paradisusvic@gmail.com
« Last Edit: July 13, 2024, 09:02 AM by paradisusvic »

magician62

  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 180
    • View Profile
    • Donate to Member
Re: Files 2 folder on steroids.
« Reply #2 on: July 13, 2024, 01:54 PM »
I can see the confusion, I am not converting the PDF. I just need a text file with thw same name.

So for

'my.pdf'

I need an empty txt file

'my.txt'

I then want the text of 'my' inside the txt file.

So we get 'my.txt' when opened the contets is teh line of text 'my'
Why an I Magician62? Because Magician1 thru 61 were gone. :)

paradisusvic

  • Participant
  • Joined in 2024
  • *
  • Posts: 73
  • Call me Vic!
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Files 2 folder on steroids.
« Reply #3 on: July 13, 2024, 04:59 PM »
Got it, coding a small CLI as an initial release exactly by your parameters @ https://github.com/paradisusis/MagiFold

(This one is a prime candidate to be expanded into a GUI with configurable options :Thmbsup:)
My name's Victor but do feel free to call me Vic!

❤️ Support on Patreon @ www.patreon.com/paradisusio

GitHub: github.com/paradisusio

🌟 Good projects deserve support 🌎🌍🌏

✉ Email / Extend your PayPal support ❤️: paradisusvic@gmail.com
« Last Edit: July 15, 2024, 08:58 AM by paradisusvic »

paradisusvic

  • Participant
  • Joined in 2024
  • *
  • Posts: 73
  • Call me Vic!
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Files 2 folder on steroids.
« Reply #4 on: July 13, 2024, 07:14 PM »
As of now, the main functionality is complete and has been pushed to GitHub

The program takes a cautious approach by processing the top directory only. It uses “.” to indicate the current directory for the MagiFold.exe executable.
My name's Victor but do feel free to call me Vic!

❤️ Support on Patreon @ www.patreon.com/paradisusio

GitHub: github.com/paradisusio

🌟 Good projects deserve support 🌎🌍🌏

✉ Email / Extend your PayPal support ❤️: paradisusvic@gmail.com
« Last Edit: July 15, 2024, 09:00 AM by paradisusvic »

paradisusvic

  • Participant
  • Joined in 2024
  • *
  • Posts: 73
  • Call me Vic!
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Files 2 folder on steroids.
« Reply #5 on: July 13, 2024, 08:41 PM »
Just added on-screen error reporting.

The program acts on the cautious side by processing top directory only ...
-paradisusvic (July 13, 2024, 07:14 PM)

This would be the only thing that remains malleable for this PDF-focused version. If you’d like it to browse the whole (sub)directory tree, feel free to say so.
My name's Victor but do feel free to call me Vic!

❤️ Support on Patreon @ www.patreon.com/paradisusio

GitHub: github.com/paradisusio

🌟 Good projects deserve support 🌎🌍🌏

✉ Email / Extend your PayPal support ❤️: paradisusvic@gmail.com
« Last Edit: July 15, 2024, 09:02 AM by paradisusvic »

paradisusvic

  • Participant
  • Joined in 2024
  • *
  • Posts: 73
  • Call me Vic!
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Files 2 folder on steroids - MagiFold v0.1.0
« Reply #6 on: July 13, 2024, 10:07 PM »
MagiFold v0.1.0


Screenshot from 2024-07-13 23-07-08.png

Notes:

- Use the "-d" or "--directory" switch followed by the source path containing PDF files.
- The special "." path (a single dot) represents the current directory for the executable file.
- Only the top level is processed. Sub-directories are skipped.
- Errors are documented on screen, including the file path and error message.

Feel free to ask if you need any further assistance!
Vic
My name's Victor but do feel free to call me Vic!

❤️ Support on Patreon @ www.patreon.com/paradisusio

GitHub: github.com/paradisusio

🌟 Good projects deserve support 🌎🌍🌏

✉ Email / Extend your PayPal support ❤️: paradisusvic@gmail.com
« Last Edit: July 15, 2024, 08:58 AM by paradisusvic »

Lintalist

  • Participant
  • Joined in 2015
  • *
  • Posts: 122
    • View Profile
    • Lintalist
    • Donate to Member
Re: Files 2 folder on steroids.
« Reply #7 on: July 17, 2024, 01:28 PM »
Preferably the Util will be in AHK as I want to learn how it is working so I can extrapolate for the future.
Just because I wanted to play around with AutoHotkey v2 (yeah yeah I know late to the party) this seems to work. v1 would be very similar apart from "FileCreateDir" which is the command to create a folder instead of "DirCreate".
Code: Autohotkey [Select]
  1. #Requires AutoHotkey v2.0+
  2.  
  3. SelectedFolder:=FileSelect("D3", , "Select a folder") ; select a folder, we don't check for cancelation so look into that
  4.  
  5. Loop Files SelectedFolder "\*.pdf" ; find all PDFs in that folder
  6.         {
  7.          SplitPath A_LoopFileFullPath, , , , &OutNameNoExt     ; get the file name without the ext.
  8.          If !FileExist(SelectedFolder "\" OutNameNoExt ".txt") ; only create a txt file if doesn't exist
  9.                 FileAppend OutNameNoExt, SelectedFolder "\" OutNameNoExt ".txt"       ; make file with file name (no ext)
  10.          DirCreate SelectedFolder "\" OutNameNoExt             ; make folder
  11.          FileMove SelectedFolder "\" OutNameNoExt ".txt", SelectedFolder "\" OutNameNoExt "\" OutNameNoExt ".txt" ; move files
  12.          FileMove SelectedFolder "\" OutNameNoExt ".pdf", SelectedFolder "\" OutNameNoExt "\" OutNameNoExt ".pdf"
  13.         }
  14. MsgBox "Done" ; bob's your uncle

Edit: adding path to FileAppend, shouldn't matter much but just to be safe(r)
« Last Edit: July 18, 2024, 10:54 AM by Lintalist »

paradisusvic

  • Participant
  • Joined in 2024
  • *
  • Posts: 73
  • Call me Vic!
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Files 2 folder on steroids.
« Reply #8 on: July 17, 2024, 02:57 PM »
Awesome!!!

Thanks for devoting the time to do the AHK script . DonationCoder is the place for making the day to fellow happy users :-*

Thanks @Lintalist  :-*
My name's Victor but do feel free to call me Vic!

❤️ Support on Patreon @ www.patreon.com/paradisusio

GitHub: github.com/paradisusio

🌟 Good projects deserve support 🌎🌍🌏

✉ Email / Extend your PayPal support ❤️: paradisusvic@gmail.com