Windows 10: Batch Numbering Files through Powershell

Discus and support Batch Numbering Files through Powershell in Windows 10 Network and Sharing to solve the problem; Hello, I'm trying to come up with a solution through Powershell that batch numbers files at the beginning of a file name without interrupting the... Discussion in 'Windows 10 Network and Sharing' started by DetectiveKn1ght, Aug 26, 2019.

  1. Batch Numbering Files through Powershell


    Hello,


    I'm trying to come up with a solution through Powershell that batch numbers files at the beginning of a file name without interrupting the rest of the file name. For example:


    Current File Names:

    John Smith.pdf

    Abel Anderson.pdf

    Mary Trinity.pdf

    .....

    Rocky Bodega.pdf

    etc.


    Desired File Names:

    1.01 John Smith.pdf

    1.02 Abel Anderson.pdf

    1.03 Mary Trinity.pdf

    ......

    1.32 Rocky Bodega.pdf

    etc.


    I'm not sure whether this function will work in the rest of my script:

    Dir *.pdf | ForEach-Object -begin { $count=1 }


    Any suggestions will help, as I have thousands of files that I need to do this for. Thanks in advance!

    :)
     
    DetectiveKn1ght, Aug 26, 2019
    #1

  2. Running PowerShell script as a batch file

    Hello Baldo,



    Thank you for writing to Microsoft Community Forums.



    I understand that you want to execute the PowerShell commands as a batch file.



    I tried executing the batch file on my machine but I was unable to execute it as the command was incomplete. However, after making some changes in the command I was able to execute the batch file.



    You can try the following command by saving it in a batch file and check if that helps.



    powershell –Command Get-AppxPackage Microsoft.3dBuilder | Remove-AppxPackage



    Also, as the query is related to running a PowerShell script using a batch file, I suggest you to post the issue on

    TechNet
    forums where we have professionals who have more knowledge about the issue.



    Hope it helps.



    Regards,

    Prakhar Khare

    Microsoft Community – Moderator
     
    Prakhar_Khare, Aug 26, 2019
    #2
  3. OneMoar Win User
    Good resources for creating batch files?

    nobody uses batch files anymore thats Ancient
    use powershell
    PowerShell Documentation
     
    OneMoar, Aug 26, 2019
    #3
  4. oily_17 Win User

    Batch Numbering Files through Powershell

    Batch Files Knowledge Base

    Don't use batch files very much but one I find useful is for creating a list of files in a directory.
    Just copy the text below into Notepad and save as Filelist.bat

    dir /a /-p /o:gen >filelist.txt

    When you run it from a folder it will create a Filelist.txt file,in the same folder, that lists all the files in that folder.Useful when you are too lazy to type all the files out yourself.
     
    oily_17, Aug 26, 2019
    #4
Thema:

Batch Numbering Files through Powershell

Loading...
  1. Batch Numbering Files through Powershell - Similar Threads - Batch Numbering Files

  2. Screen switching via batch/powershell file possible?

    in Windows 10 Software and Apps
    Screen switching via batch/powershell file possible?: Hi, I have three screens connected to my PC, 1 x TV and 2 x TFT's.I'd like to be able to automatically switch between different screens as being primary whilst disabling the others via double click on, perhaps, a batch file.Essentially I would like to be able to have three...
  3. run a powershell command like a batch file

    in Windows 10 Installation and Upgrade
    run a powershell command like a batch file: I am working as a temp on a Windows 7 to Windows 10 migration team. We've encountered a problem with some software, and a solution has been found that requires us to execute a a single command with PowerShell. However, the command is extremely long and complex, and very...
  4. Batch Rename in Powershell

    in Windows 10 Network and Sharing
    Batch Rename in Powershell: I'm trying to rename all the image files in a folder by appending a 1- in front of each file name using this command: Dir Rename-Item -NewName {$_.name -replace "IMG_*.*","1-IMG_*.*"} A typical file name is IMG_0001-Wolf.jpg. I get the following error message for each...
  5. how to add powershell batch file shortcut to taskbar

    in Windows 10 Support
    how to add powershell batch file shortcut to taskbar: Hi I have several batch files which I've created shortcuts for, and added to my windows taskbar. I now have a new batch file which contains some powershell which instructs pc to switch off screen. Please can anyone advise why Windows won't let me place this shortcut on the...
  6. how to add powershell batch file shortcut to taskbar

    in Windows 10 Performance & Maintenance
    how to add powershell batch file shortcut to taskbar: Hi I have several batch files which I've created shortcuts for, and added to my windows taskbar. I now have a new batch file which contains some powershell which instructs pc to switch off screen. Please can anyone advise why Windows won't let me place this shortcut on the...
  7. Opening Sticky Notes through a batch file

    in Windows 10 Software and Apps
    Opening Sticky Notes through a batch file: Hi, I am seeing if it is possible to make a batch file that opened sticky notes, and edited them? It would be helpful if you could, thanks. https://answers.microsoft.com/en-us/windows/forum/all/opening-sticky-notes-through-a-batch-file/bea4fc4e-f3b0-4146-b8b5-2062b4ace3dc
  8. Running PowerShell script as a batch file

    in Windows 10 Network and Sharing
    Running PowerShell script as a batch file: Can I run the Power Shell line: "C:\Windows\System32>get-appxpackage *3dbuilder* | remove-appxpackage" from a .Bat file? ***Original title: Removing bloatware***...
  9. App doesnt open through a batch file

    in Windows 10 Software and Apps
    App doesnt open through a batch file: Chaps... I have a desktop running with a few apps 24/7 feeding to a network, on the rare occasion it drops or restarts due to some update or power outage I thought I could write a simple batchfile just to restart everything automatically. Problem is 1 app refuses to...
  10. How to run batch file with powershell

    in Windows 10 Network and Sharing
    How to run batch file with powershell: I created a basic batch file that uses "net share" to share a local path. I saved the batch file. When I double click the file I get "access is denied"... note, I am logged on as a admin. Anyways... I figure it has to be run using power shell. I do not know much about...