DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Automated folder maker  (Read 11,902 times)

KoenFugro

  • Participant
  • Joined in 2008
  • *
  • Posts: 26
Automated folder maker
« on: December 15, 2008, 09: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
  • **
  • Posts: 21
Re: Automated folder maker
« Reply #1 on: December 15, 2008, 05:16 PM »
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*

Code
#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, 02:27 PM by aCkRiTe »

KoenFugro

  • Participant
  • Joined in 2008
  • *
  • Posts: 26
Re: Automated folder maker
« Reply #2 on: December 16, 2008, 10: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

  • Lokoman.z
  • Participant
  • Joined in 2007
  • *
  • Posts: 2
Re: Automated folder maker
« Reply #3 on: December 27, 2008, 03:04 PM »
filenanny can do the work too.

Original address: https://www.donationcoder.com/forum/index.php?topic=16179.0