Untitled

mail@pastecode.io avatar
unknown
plain_text
24 days ago
1.1 kB
1
Indexable
Never
#!/bin/bash

# Source folder containing files to split
source_folder="C:\Users\Naveen Kumar\Documents\all_csv_pdf_xlsx"

# Destination folder to store split folders
destination_folder="C:\Users\Naveen Kumar\Documents\destfolder"

# Total number of files to split
total_files=1531

# Number of files to place in each split folder
files_per_folder=99

# Create the destination folder if it doesn't exist
mkdir -p "$destination_folder"

# Counter for split folders
folder_counter=1

# Loop through files in the source folder
for file in "$source_folder"/*; do
    # Create a new folder if needed
    if (( folder_counter % files_per_folder == 1 )); then
        mkdir -p "$destination_folder/split_$(( (folder_counter - 1) / files_per_folder + 1 ))"
    fi

    # Move the file to the current split folder
    mv "$file" "$destination_folder/split_$(( (folder_counter - 1) / files_per_folder + 1 ))/"

    # Increment the counter
    ((folder_counter++))

    # Exit loop if all files have been processed
    if (( folder_counter > total_files )); then
        break
    fi
done
Leave a Comment