Actually, to only list *.pdf files, you would need to modify the "dir" command line syntax that is listing the files. In the script, I have the following command line that is listing all files in a given directory: dir "%fldr%" /a-d /b What this is stating is "list all items in a bare, just display the file name, format (/b ) that are not directories (/a-d) in the specified directory (%fldr%)" To only show .pdf files, you would need to modify this command to the following: dir "%fldr%\*.pdf" /a-d /b To get a better understanding of what these command lines are doing, open a command prompt and run them from there, changing the %fldr% to a valid path. Something like this: dir "%userprofile%\documents\*.pdf" /a-d /b For a full list of command line switches for the 'dir' command, run dir /? at the command prompt. And if you want more information on what the "tokens=*" is, look at the help for the "for" command: ( for /? ) So, your new batch file would look like this: @echo off ::Change this variable to the directory containing the files Set "fldr=D:\Your Files Location" for /f "tokens=*" %%a in ('dir "%fldr%\*.pdf" /a-d /b') do md "%fldr%\%%~na"&move "%fldr%\%%a" "%fldr%\%%~na"