Last active
July 5, 2021 18:13
-
-
Save rickkk856/8ca3fd243d8a8ac3e106a44e55c4f5dc to your computer and use it in GitHub Desktop.
Copy or Move Files with Same Name.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "C:\\Users\\Pichau\\RPLAN-Toolbox\\output_80K_B_ORGANIZED\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "%cd \"C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "## Compare 2 folders, if one filename in folder A == filename in folder B\n", | |
| "## Then Move filenameB to folderC" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 24, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Total number of files source path: 210\n", | |
| "Total number of files folder path: 103\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "import shutil\n", | |
| "import os\n", | |
| "\n", | |
| "#Folder to check filenames\n", | |
| "folder_path = r'C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/4_Room'\n", | |
| "source_path = r'C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/Original'\n", | |
| "new_path = r'C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train'\n", | |
| "\n", | |
| "# Make a list of filenames and filepaths of images that you want to move\n", | |
| "Source_names = []\n", | |
| "Source_paths = []\n", | |
| "for img in os.listdir(source_path):\n", | |
| " Source_path = os.path.join(source_path, img)\n", | |
| " Source_names.append(img)\n", | |
| " Source_paths.append(Source_path)\n", | |
| "\n", | |
| "\n", | |
| "total = len(Source_paths)\n", | |
| "print(\"Total number of files source path: \", total)\n", | |
| "\n", | |
| "# Make a list of filenames and filepaths of images that you want check filenames\n", | |
| "file_paths = []\n", | |
| "file_names = []\n", | |
| "for img in os.listdir(folder_path):\n", | |
| " file_path = os.path.join(folder_path, img)\n", | |
| " file_names.append(img)\n", | |
| " file_paths.append(file_path)\n", | |
| " \n", | |
| "total = len(file_names)\n", | |
| "\n", | |
| "print(\"Total number of files folder path: \", total)\n", | |
| "#print(\"Filenames in folder path: \", file_names)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 25, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Moved File 10063.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\10063.png\n", | |
| "Moved File 10224.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\10224.png\n", | |
| "Moved File 10852.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\10852.png\n", | |
| "Moved File 11690.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\11690.png\n", | |
| "Moved File 1211.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\1211.png\n", | |
| "Moved File 122.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\122.png\n", | |
| "Moved File 13880.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\13880.png\n", | |
| "Moved File 14371.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\14371.png\n", | |
| "Moved File 15344.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\15344.png\n", | |
| "Moved File 15523.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\15523.png\n", | |
| "Moved File 1736.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\1736.png\n", | |
| "Moved File 18869.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\18869.png\n", | |
| "Moved File 18919.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\18919.png\n", | |
| "Moved File 196.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\196.png\n", | |
| "Moved File 19809.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\19809.png\n", | |
| "Moved File 21181.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\21181.png\n", | |
| "Moved File 228.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\228.png\n", | |
| "Moved File 22869.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\22869.png\n", | |
| "Moved File 23717.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\23717.png\n", | |
| "Moved File 23754.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\23754.png\n", | |
| "Moved File 24442.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\24442.png\n", | |
| "Moved File 26529.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\26529.png\n", | |
| "Moved File 27439.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\27439.png\n", | |
| "Moved File 29578.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\29578.png\n", | |
| "Moved File 29654.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\29654.png\n", | |
| "Moved File 29833.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\29833.png\n", | |
| "Moved File 29837.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\29837.png\n", | |
| "Moved File 29879.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\29879.png\n", | |
| "Moved File 30059.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\30059.png\n", | |
| "Moved File 30127.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\30127.png\n", | |
| "Moved File 30609.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\30609.png\n", | |
| "Moved File 30715.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\30715.png\n", | |
| "Moved File 31904.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\31904.png\n", | |
| "Moved File 32625.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\32625.png\n", | |
| "Moved File 33196.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\33196.png\n", | |
| "Moved File 33412.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\33412.png\n", | |
| "Moved File 34087.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\34087.png\n", | |
| "Moved File 34710.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\34710.png\n", | |
| "Moved File 35624.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\35624.png\n", | |
| "Moved File 3642.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\3642.png\n", | |
| "Moved File 36854.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\36854.png\n", | |
| "Moved File 3714.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\3714.png\n", | |
| "Moved File 386.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\386.png\n", | |
| "Moved File 40285.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\40285.png\n", | |
| "Moved File 41562.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\41562.png\n", | |
| "Moved File 41796.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\41796.png\n", | |
| "Moved File 42957.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\42957.png\n", | |
| "Moved File 4329.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\4329.png\n", | |
| "Moved File 43893.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\43893.png\n", | |
| "Moved File 45345.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\45345.png\n", | |
| "Moved File 5023.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\5023.png\n", | |
| "Moved File 5041.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\5041.png\n", | |
| "Moved File 51930.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\51930.png\n", | |
| "Moved File 52389.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\52389.png\n", | |
| "Moved File 5468.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\5468.png\n", | |
| "Moved File 55710.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\55710.png\n", | |
| "Moved File 56017.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\56017.png\n", | |
| "Moved File 57857.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\57857.png\n", | |
| "Moved File 58063.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\58063.png\n", | |
| "Moved File 58145.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\58145.png\n", | |
| "Moved File 58157.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\58157.png\n", | |
| "Moved File 58312.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\58312.png\n", | |
| "Moved File 58550.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\58550.png\n", | |
| "Moved File 59419.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\59419.png\n", | |
| "Moved File 62335.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\62335.png\n", | |
| "Moved File 62390.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\62390.png\n", | |
| "Moved File 62767.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\62767.png\n", | |
| "Moved File 63152.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\63152.png\n", | |
| "Moved File 64142.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\64142.png\n", | |
| "Moved File 64588.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\64588.png\n", | |
| "Moved File 64610.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\64610.png\n", | |
| "Moved File 66697.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\66697.png\n", | |
| "Moved File 67076.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\67076.png\n", | |
| "Moved File 67551.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\67551.png\n", | |
| "Moved File 67814.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\67814.png\n", | |
| "Moved File 68171.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\68171.png\n", | |
| "Moved File 68467.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\68467.png\n", | |
| "Moved File 69254.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\69254.png\n", | |
| "Moved File 69762.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\69762.png\n", | |
| "Moved File 70174.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\70174.png\n", | |
| "Moved File 70307.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\70307.png\n", | |
| "Moved File 70685.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\70685.png\n", | |
| "Moved File 71010.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\71010.png\n", | |
| "Moved File 71011.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\71011.png\n", | |
| "Moved File 71084.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\71084.png\n", | |
| "Moved File 71513.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\71513.png\n", | |
| "Moved File 7179.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\7179.png\n", | |
| "Moved File 72416.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\72416.png\n", | |
| "Moved File 73060.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\73060.png\n", | |
| "Moved File 73447.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\73447.png\n", | |
| "Moved File 73815.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\73815.png\n" | |
| ] | |
| }, | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Moved File 73835.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\73835.png\n", | |
| "Moved File 74160.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\74160.png\n", | |
| "Moved File 74373.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\74373.png\n", | |
| "Moved File 74563.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\74563.png\n", | |
| "Moved File 75567.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\75567.png\n", | |
| "Moved File 75943.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\75943.png\n", | |
| "Moved File 76877.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\76877.png\n", | |
| "Moved File 7710.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\7710.png\n", | |
| "Moved File 77828.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\77828.png\n", | |
| "Moved File 79306.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\79306.png\n", | |
| "Moved File 79687.png to C:/Users/Pichau/RPLAN-Toolbox/output_80K_B_ORGANIZED/train\\79687.png\n", | |
| "\n", | |
| "\n", | |
| "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$[ Files Moved Successfully ]$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "for img in os.listdir(source_path):\n", | |
| " original_path = os.path.join(source_path, img)\n", | |
| " move_path = os.path.join(new_path, img)\n", | |
| " if img in file_names:\n", | |
| " dest = shutil.move(original_path, move_path) # OR shutil Copy\n", | |
| " print(\"Moved File\",img,\"to\",move_path)\n", | |
| " \n", | |
| "print(\"\\n\\n\"+\"$\"*33+\"[ Files Moved Successfully ]\"+\"$\"*33)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "## Randomize a number of files and move to new folder" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 20, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "10% of Total files is == 454.90000000000003\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "FilesTotal = 4549\n", | |
| "Percentage = FilesTotal * 0.1\n", | |
| "print(\"10% of Total files is == \", Percentage)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 22, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Enter the Source Directory : C:\\Users\\Pichau\\pytorch-CycleGAN-and-pix2pix\\datasets\\5_Room_4K\\train\n", | |
| "Enter the Destination Directory : C:\\Users\\Pichau\\pytorch-CycleGAN-and-pix2pix\\datasets\\5_Room_4K\\test\n", | |
| "Enter The Number of Files To Select : 455\n", | |
| "%%%%%%%%%%%%%%%%%%%%%%%%%{ Details Of Transfer }%%%%%%%%%%%%%%%%%%%%%%%%%\n", | |
| "\n", | |
| "\n", | |
| "List of Files Moved to C:\\Users\\Pichau\\pytorch-CycleGAN-and-pix2pix\\datasets\\5_Room_4K\\test :-\n", | |
| "1} 3191.png\n", | |
| "2} 1046.png\n", | |
| "3} 30468.png\n", | |
| "4} 69411.png\n", | |
| "5} 29899.png\n", | |
| "6} 33428.png\n", | |
| "7} 50552.png\n", | |
| "8} 69777.png\n", | |
| "9} 25451.png\n", | |
| "10} 63043.png\n", | |
| "11} 65538.png\n", | |
| "12} 54274.png\n", | |
| "13} 17753.png\n", | |
| "14} 54237.png\n", | |
| "15} 15373.png\n", | |
| "16} 36268.png\n", | |
| "17} 12886.png\n", | |
| "18} 60022.png\n", | |
| "19} 79641.png\n", | |
| "20} 31146.png\n", | |
| "21} 42444.png\n", | |
| "22} 64575.png\n", | |
| "23} 9202.png\n", | |
| "24} 34839.png\n", | |
| "25} 31033.png\n", | |
| "26} 68089.png\n", | |
| "27} 44351.png\n", | |
| "28} 3648.png\n", | |
| "29} 49669.png\n", | |
| "30} 79896.png\n", | |
| "31} 33518.png\n", | |
| "32} 57375.png\n", | |
| "33} 15440.png\n", | |
| "34} 79362.png\n", | |
| "35} 50914.png\n", | |
| "36} 14417.png\n", | |
| "37} 18865.png\n", | |
| "38} 51517.png\n", | |
| "39} 76939.png\n", | |
| "40} 59560.png\n", | |
| "41} 44385.png\n", | |
| "42} 2397.png\n", | |
| "43} 47376.png\n", | |
| "44} 25975.png\n", | |
| "45} 46954.png\n", | |
| "46} 42609.png\n", | |
| "47} 7705.png\n", | |
| "48} 65689.png\n", | |
| "49} 31754.png\n", | |
| "50} 5092.png\n", | |
| "51} 20163.png\n", | |
| "52} 49692.png\n", | |
| "53} 466.png\n", | |
| "54} 44012.png\n", | |
| "55} 77745.png\n", | |
| "56} 2044.png\n", | |
| "57} 45869.png\n", | |
| "58} 15946.png\n", | |
| "59} 57702.png\n", | |
| "60} 78758.png\n", | |
| "61} 57899.png\n", | |
| "62} 50228.png\n", | |
| "63} 3734.png\n", | |
| "64} 13204.png\n", | |
| "65} 69053.png\n", | |
| "66} 36240.png\n", | |
| "67} 8029.png\n", | |
| "68} 74084.png\n", | |
| "69} 71549.png\n", | |
| "70} 80139.png\n", | |
| "71} 32351.png\n", | |
| "72} 1986.png\n", | |
| "73} 7390.png\n", | |
| "74} 49356.png\n", | |
| "75} 68616.png\n", | |
| "76} 18398.png\n", | |
| "77} 68756.png\n", | |
| "78} 55846.png\n", | |
| "79} 67633.png\n", | |
| "80} 52368.png\n", | |
| "81} 1088.png\n", | |
| "82} 33440.png\n", | |
| "83} 12445.png\n", | |
| "84} 15262.png\n", | |
| "85} 1707.png\n", | |
| "86} 51126.png\n", | |
| "87} 19311.png\n", | |
| "88} 75854.png\n", | |
| "89} 16712.png\n", | |
| "90} 70210.png\n", | |
| "91} 26628.png\n", | |
| "92} 45844.png\n", | |
| "93} 79661.png\n", | |
| "94} 34071.png\n", | |
| "95} 20159.png\n", | |
| "96} 31400.png\n", | |
| "97} 49910.png\n", | |
| "98} 21464.png\n", | |
| "99} 57397.png\n", | |
| "100} 71290.png\n", | |
| "101} 76097.png\n", | |
| "102} 56670.png\n", | |
| "103} 40399.png\n", | |
| "104} 75695.png\n", | |
| "105} 61137.png\n", | |
| "106} 63295.png\n", | |
| "107} 37538.png\n", | |
| "108} 3180.png\n", | |
| "109} 37236.png\n", | |
| "110} 77335.png\n", | |
| "111} 19757.png\n", | |
| "112} 35500.png\n", | |
| "113} 6342.png\n", | |
| "114} 47855.png\n", | |
| "115} 22024.png\n", | |
| "116} 26064.png\n", | |
| "117} 32662.png\n", | |
| "118} 16042.png\n", | |
| "119} 38804.png\n", | |
| "120} 12511.png\n", | |
| "121} 78492.png\n", | |
| "122} 14250.png\n", | |
| "123} 73030.png\n", | |
| "124} 15785.png\n", | |
| "125} 54044.png\n", | |
| "126} 48490.png\n", | |
| "127} 80319.png\n", | |
| "128} 73162.png\n", | |
| "129} 61127.png\n", | |
| "130} 60833.png\n", | |
| "131} 63959.png\n", | |
| "132} 57710.png\n", | |
| "133} 65440.png\n", | |
| "134} 61946.png\n", | |
| "135} 4753.png\n", | |
| "136} 29058.png\n", | |
| "137} 63773.png\n", | |
| "138} 30831.png\n", | |
| "139} 43278.png\n", | |
| "140} 10711.png\n", | |
| "141} 32005.png\n", | |
| "142} 11797.png\n", | |
| "143} 71085.png\n", | |
| "144} 48464.png\n", | |
| "145} 13985.png\n", | |
| "146} 68716.png\n", | |
| "147} 1425.png\n", | |
| "148} 42908.png\n", | |
| "149} 74801.png\n", | |
| "150} 6201.png\n", | |
| "151} 38602.png\n", | |
| "152} 1894.png\n", | |
| "153} 73988.png\n", | |
| "154} 43907.png\n", | |
| "155} 30046.png\n", | |
| "156} 66919.png\n", | |
| "157} 41296.png\n", | |
| "158} 75841.png\n", | |
| "159} 68860.png\n", | |
| "160} 67960.png\n", | |
| "161} 76326.png\n", | |
| "162} 3735.png\n", | |
| "163} 34775.png\n", | |
| "164} 38743.png\n", | |
| "165} 79261.png\n", | |
| "166} 69031.png\n", | |
| "167} 63855.png\n", | |
| "168} 24276.png\n", | |
| "169} 14901.png\n", | |
| "170} 77570.png\n", | |
| "171} 79894.png\n", | |
| "172} 47974.png\n", | |
| "173} 74316.png\n", | |
| "174} 42629.png\n", | |
| "175} 47389.png\n", | |
| "176} 31524.png\n", | |
| "177} 14701.png\n", | |
| "178} 3739.png\n", | |
| "179} 27044.png\n", | |
| "180} 25995.png\n", | |
| "181} 66735.png\n", | |
| "182} 40125.png\n", | |
| "183} 46456.png\n", | |
| "184} 18534.png\n", | |
| "185} 52891.png\n", | |
| "186} 54579.png\n", | |
| "187} 67932.png\n", | |
| "188} 65593.png\n", | |
| "189} 13423.png\n", | |
| "190} 37131.png\n", | |
| "191} 21469.png\n", | |
| "192} 43441.png\n", | |
| "193} 15551.png\n", | |
| "194} 3567.png\n", | |
| "195} 51396.png\n", | |
| "196} 71652.png\n", | |
| "197} 35878.png\n", | |
| "198} 78040.png\n", | |
| "199} 80536.png\n", | |
| "200} 32708.png\n", | |
| "201} 52979.png\n", | |
| "202} 49023.png\n", | |
| "203} 19040.png\n", | |
| "204} 2449.png\n", | |
| "205} 53384.png\n", | |
| "206} 7318.png\n", | |
| "207} 4870.png\n", | |
| "208} 1251.png\n", | |
| "209} 34956.png\n", | |
| "210} 62038.png\n", | |
| "211} 43255.png\n", | |
| "212} 19351.png\n", | |
| "213} 41220.png\n", | |
| "214} 71878.png\n", | |
| "215} 59169.png\n", | |
| "216} 24147.png\n", | |
| "217} 36385.png\n", | |
| "218} 37200.png\n", | |
| "219} 33172.png\n", | |
| "220} 21890.png\n", | |
| "221} 45224.png\n", | |
| "222} 44889.png\n", | |
| "223} 78243.png\n", | |
| "224} 17114.png\n", | |
| "225} 44195.png\n", | |
| "226} 950.png\n", | |
| "227} 74369.png\n", | |
| "228} 80368.png\n", | |
| "229} 48069.png\n", | |
| "230} 69247.png\n", | |
| "231} 10888.png\n", | |
| "232} 789.png\n", | |
| "233} 1225.png\n", | |
| "234} 35952.png\n", | |
| "235} 16896.png\n", | |
| "236} 58110.png\n", | |
| "237} 34741.png\n", | |
| "238} 45124.png\n", | |
| "239} 78691.png\n", | |
| "240} 21605.png\n", | |
| "241} 57248.png\n", | |
| "242} 52733.png\n", | |
| "243} 64021.png\n", | |
| "244} 62864.png\n", | |
| "245} 2884.png\n", | |
| "246} 45611.png\n", | |
| "247} 80442.png\n", | |
| "248} 47896.png\n", | |
| "249} 79799.png\n", | |
| "250} 62078.png\n", | |
| "251} 34254.png\n", | |
| "252} 37036.png\n", | |
| "253} 45226.png\n", | |
| "254} 42007.png\n", | |
| "255} 36943.png\n", | |
| "256} 44425.png\n", | |
| "257} 70075.png\n", | |
| "258} 80018.png\n", | |
| "259} 36227.png\n", | |
| "260} 80324.png\n", | |
| "261} 20566.png\n", | |
| "262} 29629.png\n", | |
| "263} 71836.png\n", | |
| "264} 42610.png\n", | |
| "265} 27735.png\n", | |
| "266} 76266.png\n", | |
| "267} 42824.png\n", | |
| "268} 20393.png\n", | |
| "269} 78722.png\n", | |
| "270} 19114.png\n", | |
| "271} 36514.png\n", | |
| "272} 44276.png\n", | |
| "273} 35682.png\n", | |
| "274} 62225.png\n", | |
| "275} 30040.png\n", | |
| "276} 19647.png\n", | |
| "277} 68846.png\n", | |
| "278} 46431.png\n", | |
| "279} 64764.png\n", | |
| "280} 35137.png\n", | |
| "281} 42846.png\n", | |
| "282} 13744.png\n", | |
| "283} 80256.png\n", | |
| "284} 19641.png\n", | |
| "285} 38674.png\n", | |
| "286} 72827.png\n", | |
| "287} 80510.png\n", | |
| "288} 27378.png\n", | |
| "289} 55627.png\n", | |
| "290} 26123.png\n", | |
| "291} 41863.png\n", | |
| "292} 77858.png\n", | |
| "293} 14588.png\n", | |
| "294} 5771.png\n", | |
| "295} 8620.png\n", | |
| "296} 18094.png\n", | |
| "297} 60648.png\n", | |
| "298} 69056.png\n", | |
| "299} 76769.png\n", | |
| "300} 68732.png\n", | |
| "301} 287.png\n", | |
| "302} 49093.png\n", | |
| "303} 28870.png\n", | |
| "304} 16575.png\n", | |
| "305} 64339.png\n", | |
| "306} 19480.png\n", | |
| "307} 74648.png\n", | |
| "308} 71425.png\n", | |
| "309} 49886.png\n", | |
| "310} 15766.png\n", | |
| "311} 41070.png\n", | |
| "312} 29188.png\n", | |
| "313} 14448.png\n", | |
| "314} 3856.png\n", | |
| "315} 51325.png\n", | |
| "316} 20192.png\n", | |
| "317} 78831.png\n", | |
| "318} 33551.png\n", | |
| "319} 80050.png\n", | |
| "320} 34297.png\n", | |
| "321} 59602.png\n", | |
| "322} 32188.png\n", | |
| "323} 33434.png\n", | |
| "324} 26811.png\n", | |
| "325} 26890.png\n", | |
| "326} 73403.png\n", | |
| "327} 22617.png\n", | |
| "328} 7581.png\n", | |
| "329} 42075.png\n", | |
| "330} 59236.png\n", | |
| "331} 45508.png\n", | |
| "332} 64169.png\n", | |
| "333} 19713.png\n", | |
| "334} 28618.png\n", | |
| "335} 73469.png\n", | |
| "336} 33532.png\n", | |
| "337} 33036.png\n", | |
| "338} 42399.png\n", | |
| "339} 60888.png\n", | |
| "340} 31923.png\n", | |
| "341} 69536.png\n", | |
| "342} 23726.png\n", | |
| "343} 627.png\n", | |
| "344} 30637.png\n", | |
| "345} 33912.png\n", | |
| "346} 33863.png\n", | |
| "347} 19039.png\n", | |
| "348} 56989.png\n", | |
| "349} 31785.png\n", | |
| "350} 69226.png\n", | |
| "351} 70720.png\n", | |
| "352} 38265.png\n", | |
| "353} 22768.png\n", | |
| "354} 34355.png\n", | |
| "355} 41678.png\n", | |
| "356} 44735.png\n", | |
| "357} 2692.png\n", | |
| "358} 65752.png\n", | |
| "359} 20509.png\n", | |
| "360} 64360.png\n", | |
| "361} 67786.png\n", | |
| "362} 62077.png\n", | |
| "363} 21940.png\n", | |
| "364} 24056.png\n", | |
| "365} 12149.png\n", | |
| "366} 22601.png\n", | |
| "367} 38785.png\n", | |
| "368} 46054.png\n", | |
| "369} 80177.png\n", | |
| "370} 46970.png\n", | |
| "371} 4729.png\n", | |
| "372} 31728.png\n", | |
| "373} 46501.png\n", | |
| "374} 40552.png\n", | |
| "375} 75273.png\n", | |
| "376} 34136.png\n", | |
| "377} 73951.png\n", | |
| "378} 31781.png\n", | |
| "379} 34640.png\n", | |
| "380} 73591.png\n", | |
| "381} 44971.png\n", | |
| "382} 28281.png\n", | |
| "383} 16152.png\n", | |
| "384} 44028.png\n", | |
| "385} 58559.png\n", | |
| "386} 66960.png\n", | |
| "387} 24939.png\n", | |
| "388} 77213.png\n", | |
| "389} 22001.png\n", | |
| "390} 1361.png\n", | |
| "391} 19886.png\n", | |
| "392} 45762.png\n", | |
| "393} 34927.png\n", | |
| "394} 53378.png\n", | |
| "395} 67698.png\n", | |
| "396} 16419.png\n", | |
| "397} 57288.png\n", | |
| "398} 62340.png\n", | |
| "399} 58058.png\n", | |
| "400} 4805.png\n", | |
| "401} 66864.png\n", | |
| "402} 40684.png\n", | |
| "403} 77696.png\n", | |
| "404} 44566.png\n", | |
| "405} 68326.png\n", | |
| "406} 40306.png\n", | |
| "407} 32690.png\n", | |
| "408} 51313.png\n", | |
| "409} 80360.png\n", | |
| "410} 46171.png\n", | |
| "411} 14058.png\n", | |
| "412} 30993.png\n", | |
| "413} 26686.png\n", | |
| "414} 66431.png\n", | |
| "415} 30859.png\n", | |
| "416} 25139.png\n", | |
| "417} 38959.png\n", | |
| "418} 32767.png\n", | |
| "419} 218.png\n", | |
| "420} 57875.png\n", | |
| "421} 71263.png\n", | |
| "422} 53068.png\n", | |
| "423} 37290.png\n", | |
| "424} 73844.png\n", | |
| "425} 70639.png\n", | |
| "426} 79627.png\n", | |
| "427} 64457.png\n", | |
| "428} 48007.png\n", | |
| "429} 11374.png\n", | |
| "430} 76869.png\n", | |
| "431} 80136.png\n", | |
| "432} 67993.png\n", | |
| "433} 27456.png\n", | |
| "434} 51678.png\n", | |
| "435} 19979.png\n", | |
| "436} 31302.png\n", | |
| "437} 61047.png\n", | |
| "438} 73648.png\n", | |
| "439} 3685.png\n", | |
| "440} 92.png\n", | |
| "441} 62789.png\n", | |
| "442} 13556.png\n", | |
| "443} 52932.png\n", | |
| "444} 78810.png\n", | |
| "445} 59809.png\n", | |
| "446} 39697.png\n", | |
| "447} 52466.png\n", | |
| "448} 60574.png\n", | |
| "449} 42478.png\n", | |
| "450} 34078.png\n", | |
| "451} 67550.png\n", | |
| "452} 20660.png\n", | |
| "453} 2987.png\n", | |
| "454} 50375.png\n", | |
| "455} 43084.png\n", | |
| "\n", | |
| "\n", | |
| "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$[ Files Moved Successfully ]$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "import os, random, shutil\n", | |
| "\n", | |
| "#Prompting user to enter number of files to select randomly along with directory\n", | |
| "source=input(\"Enter the Source Directory : \")\n", | |
| "dest=input(\"Enter the Destination Directory : \")\n", | |
| "no_of_files=int(input(\"Enter The Number of Files To Select : \"))\n", | |
| "\n", | |
| "print(\"%\"*25+\"{ Details Of Transfer }\"+\"%\"*25)\n", | |
| "print(\"\\n\\nList of Files Moved to %s :-\"%(dest))\n", | |
| "\n", | |
| "#Using for loop to randomly choose multiple files\n", | |
| "for i in range(no_of_files):\n", | |
| " #Variable random_file stores the name of the random file chosen\n", | |
| " random_file=random.choice(os.listdir(source))\n", | |
| " print(\"%d} %s\"%(i+1,random_file))\n", | |
| " source_file=\"%s/%s\"%(source,random_file)\n", | |
| " dest_file=dest\n", | |
| " #\"shutil.move\" function moves file from one directory to another\n", | |
| " shutil.move(source_file,dest_file)\n", | |
| "\n", | |
| "print(\"\\n\\n\"+\"$\"*33+\"[ Files Moved Successfully ]\"+\"$\"*33)" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3", | |
| "language": "python", | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.8.5" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 4 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment