Electron microscopy
 
Move File(s) from One Directory to Another
- Python for Integrated Circuits -
- An Online Book -
Python for Integrated Circuits                                                                                   http://www.globalsino.com/ICs/        


Chapter/Index: Introduction | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | Appendix

=================================================================================

============================================

Move files from one directory to another (a file with that name in the destination must not exist or an exception will be raised): code:
          Move files from one directory to another (the file must already exist)
Before move:          
          Move files from one directory to another (the file must already exist)
          Move files from one directory to another (the file must already exist)
After move:          
          Move files from one directory to another (the file must already exist)
          Move files from one directory to another (the file must already exist)

============================================

Move files from one directory to another (the file with the same name in the destination will silently be replaced if the file already exist): code:
          Move files from one directory to another (the file must already exist)
Before move:          
          Move files from one directory to another (the file must already exist)
          Move files from one directory to another (the file must already exist)
After move:          
          Move files from one directory to another (the file must already exist)
          Move files from one directory to another (the file must already exist)

============================================

Move files from one directory to another (a file with that name in the destination must not exist or an exception will be raised): code:
          Move files from one directory to another (the file must already exist)
Before move:          
          Move files from one directory to another (the file must already exist)
          Move files from one directory to another (the file must already exist)
After move:          
          Move files from one directory to another (the file must already exist)
          Move files from one directory to another (the file must already exist)

============================================

Create a new folder and then copy all files from a folder to the new folder and rename the file, and then open the file. If the folder exists, then no file will be copied, but the file will still be opened. Code:
        Create a new folder and then copy all files from a folder to the new folder and rename the file, and then open the file. If the folder exists, then no file will be copied, but the file will still be opened
Input:        
        Create a new folder and then copy all files from a folder to the new folder and rename the file, and then open the file. If the folder exists, then no file will be copied, but the file will still be opened        
Output 1:
        Create a new folder and then copy all files from a folder to the new folder and rename the file, and then open the file. If the folder exists, then no file will be copied, but the file will still be opened       
Output 2:
        Create a new folder and then copy all files from a folder to the new folder and rename the file, and then open the file. If the folder exists, then no file will be copied, but the file will still be opened

============================================

Move (copy and then delete) all original files from a folder to the new folder. If the folder exists, then do nothing: code:

         Move files from one directory to another (the file must already exist)

Input:      

         Move files from one directory to another (the file must already exist)

          Move files from one directory to another (the file must already exist)

Output:      

          Move files from one directory to another (the file must already exist)

          Move files from one directory to another (the file must already exist)

         Move files from one directory to another (the file must already exist)

============================================

Troubleshooting: Error occurs when running the script below (code):

          Move files from one directory to another (the file must already exist)
Error is:          
          File "C:/GlobalSino2/ICs/page4853movFiles5.py", line 16, in <module>
          os.rename(source, destination)
          FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\yyliao\\Downloads\\AAPL.csv' -> 'C:\\0Python\\Stocks\\IndividualStocks\\AAPL.csv'
         
Correct script (code):          
          Move files from one directory to another (the file must already exist)

====================================================

Sort/move files, which was pasted to desktop, to specific folders: code:
         Monitor changes in a folder


         



         


         
         
         
         
         
         
         
         
         
         
         
         
         
         

 

 

 

 

 

 

 

 

 

 

=================================================================================