uploading files from Jürg’s backup to new file server filebase24.com

Save folder names into a text file before renaming #

This is the folder structure from the download backup. We need to rename these folder names to remove skus (4-digit numbers), commas and other special characters before uploading it to the linux server via ftp.

Here is a simple PowerShell script that will:

  1. Iterate through each folder in the specified directory.
  2. Create a text file inside the folder.
  3. Name the text file as xyz.txt, where xyz is the original folder name.

Copy this script into a new text file in notepad called create_folder_info.ps1. Use the actual folder path to the folders you want to rename.

$path = "C:\Path\To\Your\Folders"  # Change this to your actual folder path

Get-ChildItem -Path $path -Directory | ForEach-Object {
    $folderName = $_.Name
    $textFilePath = Join-Path $_.FullName "$folderName.txt"
    
    # Create the text file with the folder name inside it
    Set-Content -Path $textFilePath -Value $folderName
}

Task: Generate an FTP Link List for All Files in Subfolders (Windows & Linux) #

Objective #

We need to generate a list of FTP links for every file in a directory and its subdirectories. This can be done before uploading (Windows method) or after uploading (Linux method). The final output is a .txt file containing all file links, which can be used for reference or sharing.

Solution 1: Windows Method (Before Uploading) #

This method uses PowerShell to list all files, convert their paths into FTP links, and save them in a .txt file.

📌 Steps: #

  1. Open Notepad and paste the following PowerShell script.
  2. Modify the paths:
    • K:\OS downloads → Replace with your source folder path.
    • ftp://yourserver.com/files → Replace with your actual FTP URL.
    • C:\Users\YourUser\Desktop\file_links.txt → Set the desired output file location.
  3. Save the file as generate_ftp_links.ps1 (choose All Files as file type).
  4. Run the script:
    • Right-click the file and select Run with PowerShell, or
    • Open PowerShell, navigate to the script’s location, and run:powershellCopyEdit.\generate_ftp_links.ps1
  5. Check the generated file_links.txt for all file paths converted into FTP URLs.

📌 Windows PowerShell Script #

powershellCopyEdit$basePath = "K:\OS downloads"  # Change this to your folder path
$ftpBase = "ftp://yourserver.com/files"  # Change this to your actual FTP base URL
$outputFile = "C:\Users\YourUser\Desktop\file_links.txt"  # Change this to your desired output file location

Get-ChildItem -Path $basePath -Recurse -File | ForEach-Object {
    $relativePath = $_.FullName.Replace($basePath, "").Replace("\", "/").TrimStart("/")
    "$ftpBase/$relativePath"
} | Out-File -Encoding UTF8 $outputFile

Write-Host "File list saved to $outputFile"
Write-Host "Press any key to exit..." -ForegroundColor Yellow
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

What are your feelings
Updated on February 11, 2025