Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Reorganize Directory By File Count

Posted on May 26, 2020August 17, 2024 By David Kittell
$filesperfolder = 1000
$sourcePath = "c:\Pictures"
$destPath = "c:\Pictures\imgOrg"
$i = 0
$folderNum = 1

if (!(Test-Path "$destPath")) {
    New-Item -Path "$destPath" -Type Directory -Force
}

Get-ChildItem "$sourcePath\*.jpg" | % {

    New-Item -Path ($destPath + "\" + $folderNum) -Type Directory -Force
    Move-Item $_ ($destPath + "\" + $folderNum) -Verbose

    $i++
    if ($i -eq $filesperfolder) {
        $folderNum++
        $i = 0
    }
}
Originally Posted on May 26, 2020
Last Updated on August 17, 2024
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code PowerShell 1000 files per directorysplit directory to file count

Post navigation

Previous post
Next post

Related Posts

Ubuntu / Raspberry Pi – Install NGINX Load Balance DNS

Posted on February 20, 2018

sudo apt install nginx Replace the IP addresses with your IP addresses sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf-original sudo sed -i "/^\s*#/d;s/\s*#[^\"’]*$//" /etc/nginx/nginx.conf && sudo sed -i ‘/^\s*$/d’ /etc/nginx/nginx.conf Modify your config file to look like this user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 768; } http {…

Read More

Ektron – Category Template

Posted on October 31, 2014October 26, 2015

<%@ Page Language="C#" MasterPageFile="~/masterpages/content.master" AutoEventWireup="true" CodeFile="boardlanding.aspx.cs" Inherits="templates_categorylanding" Title="Category Landing Page" %> <%@ Register Assembly="Ektron.Cms.Controls" Namespace="Ektron.Cms.Controls" TagPrefix="CMS" %> <%@ Register Src="~/usercontrols/breadcrumb.ascx" TagName="Breadcrumb" TagPrefix="uc" %> <asp:Content ID="Header" ContentPlaceHolderID="ContentHeaderContentPlaceHolder" runat="server"> <!– categorylanding –> <img class="banner" alt="banner" src="/img/banner_01.jpg"> </asp:Content> <asp:Content ID="Left" ContentPlaceHolderID="LeftContentPlaceHolder" runat="Server"> <div id="crumbs"> <uc:Breadcrumb ID="breadcrumbControl" runat="server" /> </div> <img class="divider upper" alt=""…

Read More

Azure CLI – List All VMs with Details

Posted on December 24, 2017

az vm list –show-details –query ‘[].{VMName:name, OSType:storageProfile.osDisk.osType,VMSize:hardwareProfile.vmSize, Location: location,ResourceGroup:resourceGroup,PowerState:powerState, privateIPs: privateIps}’ -o table All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
©2025 David Kittell | WordPress Theme by SuperbThemes