0
0
Linux CLIscripting~15 mins

Why file management is daily work in Linux CLI - See It in Action

Choose your learning style9 modes available
Why File Management is Daily Work
📖 Scenario: You work as an office assistant who needs to organize daily reports and documents on a Linux computer. Every day, new files arrive and must be sorted into folders by date and type. This helps keep the workspace clean and makes it easy to find files later.
🎯 Goal: You will create a simple script that organizes files into folders by their file type. This shows why managing files daily is important to keep things tidy and easy to access.
📋 What You'll Learn
Create a list of file names with different extensions
Create a variable to hold the folder name for text files
Use a loop to check each file and move text files to the text folder
Print the list of files after organizing
💡 Why This Matters
🌍 Real World
Daily file management helps keep computer files organized so you can find reports, images, and notes quickly without clutter.
💼 Career
Many jobs require organizing files regularly to maintain order and efficiency, especially in offices and IT roles.
Progress0 / 4 steps
1
Create a list of files
Create a list called files with these exact file names: report1.txt, image1.png, notes.txt, photo.jpg, summary.txt
Linux CLI
Need a hint?

Use square brackets [] to create a list and put each file name in quotes separated by commas.

2
Create a folder name variable
Create a variable called text_folder and set it to the string 'TextFiles'
Linux CLI
Need a hint?

Use an equals sign = to assign the string 'TextFiles' to the variable text_folder.

3
Move text files to the folder
Use a for loop with variable file to go through files. Inside the loop, use an if statement to check if file ends with '.txt'. If yes, print Moving {file} to {text_folder} using an f-string.
Linux CLI
Need a hint?

Use for file in files: to loop. Use if file.endswith('.txt'): to check file type. Use print(f"Moving {file} to {text_folder}") to show the action.

4
Print the final list of files
Print the string 'Files after organizing:' and then print the files list on the next line.
Linux CLI
Need a hint?

Use two print statements: one for the message and one for the list.