| 1. |
Solve : Rename and Move PDF Files to Folder? |
|
Answer» Hi, Starting in Windows 2000 (1999), Microsoft added to its scripting power by introducing the Windows Script Host (WSH) and two real, built-in, programming languages (VBScript and JScript--Microsoft’s version of JavaScript). WSH scripts rely on COM objects to interface with the operating system and applications. While WSH is extremely useful and powerful, it’s limited to COM objects that are installed on the computer and doesn’t provide a command-line interface.The article goes on to explain how PowerShell is now the preference for command line scripts. Batch files can support PowerShell scripting. Please understand my concern. Hi Geek, it is new for me to hear Powershell. I'm reading it now and its good to know that there are no addtl apps needed to install but just saving it to Name.ps1 instead of .bat. Does this mean that my query above can be done using powershell? ThanksI still can't figure out how to write it in batch or in powershell but anyone who can help me with this please. Here's the scenario of the code: Code: [Select]set $nameseries = What is your name series? ForEach *.pdf { $nameseries = $nameseries +1 rename $nameseries move C:\Invoices c:\Invoices\Moved_Files Thanks a lot in advance! Quote from: austinandreikurt on August 20, 2016, 11:39:42 PM Say the series input by user is "JENNY-0000" , then the pdf file names would be JENNY-0001, JENNY-0002, JENNY-0003 and so on until all the files where renamed say there are 20 pdf files to rename, then it would be JENNY-0020 for the last item. Your task isn't very clear at this point. You've said that the user types "JENNY-0000" but haven't said why they are typing the "0000" part. Batch file commands do precise things, and if the task isn't WELL laid out then the code you get may not work.Hi, the name series depends on the user but it will always state a 5 letter word, then a hypen "-" then four 0's that will represent the max of 9999 files to rename and move.but it is also ok to just ENUMERATE the 5letter word by the user's input and the script automatically put a 4 number series starting from 0001 to 9999. Also, the reason why it needs to be 0001 instead of just 1 is to be able to sort the items when moved because JENNY-1 will have JENNY-10 as the next one instead of JENNY-2. To avoid it, we need to have it like JENNY-0001, JENNY-0002, JENNY-0003 and so on. Quote from: austinandreikurt on August 21, 2016, 05:54:45 AM Hi, the name series depends on the user but it will always state a 5 letter word, then a hypen "-" then four 0's that will represent the max of 9999 files to rename and move.but it is also ok to just enumerate the 5letter word by the user's input and the script automatically put a 4 number series starting from 0001 to 9999.What do you expect to happen when Jenny already has backup files Jenny-0001.pdf to Jenny-0020.pdf and then Jenny has some more files to save?Jenny files should be 867-5309...Hi foxidrive.the batch will just overwrite them as it is regularly cleaned-up by the user so there should be no duplicates.Test this script and let me know how it goes. Code: [Select]echo off setlocal enabledelayedexpansion set /p "name=Enter your 5 character name: " set c=10000 set "folder=Moved_Files" md "%folder%" 2>nul for %%a in (*.pdf) do if exist "%folder%\" ( set /a c+=1 move "%%a" "%folder%\!name!-!c:~-4!%%~xa" ) pause I think Jenny works at a different phone number down here. Quote from: patio on August 21, 2016, 09:18:28 AM Jenny files should be 867-5309...Wow. exactly what I need. thanks a lot foxidrive! |
|