topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Thursday December 12, 2024, 8:21 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: Automated folder maker  (Read 9530 times)

KoenFugro

  • Participant
  • Joined in 2008
  • *
  • Posts: 26
    • View Profile
    • Donate to Member
Automated folder maker
« on: December 15, 2008, 03:51 AM »
Hi all,

I have a a few directory's containing hundreds of PDF documents.
All the documents are in the root of that directory, but i want each PDF to be in a folder named the same as the PDF file.

This should be done automatically I, couse it is very time consuming if I do it by hand.
Is there a simple code / tool to do this?

Kind regards,
Koen Franssen

aCkRiTe

  • Honorary Member
  • Joined in 2007
  • **
  • default avatar
  • Posts: 21
    • View Profile
    • Donate to Member
Re: Automated folder maker
« Reply #1 on: December 15, 2008, 11:16 AM »
Here is an AHK script that should do it for you. This assumes you have 1 directory with many .pdf files in it, it will loop through getting each file name and create a new directory(within the main/root directory) with the current file name then move the file in to the new directory with the matching name.

*I have tested, but you should always have a backup or copy of the directory you're working on before using this script*

#SingleInstance Force
#Persistent
#NoEnv
SetBatchLines -1

FileSelectFolder, Root, , , Select Root Folder
If ErrorLevel = 1
Reload
Loop, %Root%\*.pdf
{
StringTrimRight, Folder, A_LoopFileName, 4
FileCreateDir, %Root%\%Folder%
FileMove, %A_LoopFileFullPath%, %Root%\%Folder%\%A_LoopFileName%
}
ExitApp
« Last Edit: December 16, 2008, 08:27 AM by aCkRiTe »

KoenFugro

  • Participant
  • Joined in 2008
  • *
  • Posts: 26
    • View Profile
    • Donate to Member
Re: Automated folder maker
« Reply #2 on: December 16, 2008, 04:52 AM »
Thanks aCkRiTe!

I tested this script and it works great!
I looked in your code and noticed that I can use it for other files too!


lokoman

  • Participant
  • Joined in 2007
  • *
  • Posts: 2
    • View Profile
    • Donate to Member
Re: Automated folder maker
« Reply #3 on: December 27, 2008, 09:04 AM »
filenanny can do the work too.