S-Splitter:革新你嘅文件管理,精確分割到1GB

提示: 作者被禁止或刪除 內容自動屏蔽

提示: 作者被禁止或刪除 內容自動屏蔽

TOP

提示: 作者被禁止或刪除 內容自動屏蔽

TOP

提示: 作者被禁止或刪除 內容自動屏蔽

TOP

回覆 1# BS_Man



    本來寫程式賺錢係天公地道, 不過你去討論寫程式O既地方為自己個程式o既賣廣告, 就有O的那個,
重要賣關子 ???
     等睇各路寫程式O既大大發言恥笑, 再教用各項公開程式碼做到9成9效果 .

TOP

  1. import os
  2. import subprocess
  3. import tkinter as tk
  4. from tkinter import filedialog


  5. def split_file():
  6.      # Get file path and target size
  7.      file_path = file_path_entry.get()
  8.      target_size_mb = int(target_size_entry.get())

  9.      # Calculate the target file size (in bytes)
  10.      target_size_bytes = target_size_mb * 1024 * 1024

  11.      #Create output file directory
  12.      output_dir = os.path.dirname(file_path) + '/split_files'
  13.      os.makedirs(output_dir, exist_ok=True)

  14.      # Split file command line command
  15.      split_cmd = f'split -b {target_size_bytes} "{file_path}" "{output_dir}/part"'

  16.      # Execute the split file command line command
  17.      subprocess.run(split_cmd, shell=True)

  18.      # Split completion prompt
  19.      tk.messagebox.showinfo('Split file', 'The file has been successfully split into partial files!')


  20. def merge_files():
  21.      # Get the merged file path and split file directory
  22.      output_file_path = output_file_entry.get()
  23.      input_dir = input_dir_entry.get()

  24.      # Merge file command line instructions
  25.      merge_cmd = f'cat "{input_dir}"/part* > "{output_file_path}"'

  26.      # Execute merge file command line instructions
  27.      subprocess.run(merge_cmd, shell=True)

  28.      # Merge completion prompt
  29.      tk.messagebox.showinfo('Merge files', 'Files have been merged successfully!')


  30. def browse_file():
  31.      #Open the file dialog box and get the file path
  32.      file_path = filedialog.askopenfilename()
  33.      file_path_entry.delete(0, tk.END)
  34.      file_path_entry.insert(0, file_path)


  35. def browse_output_file():
  36.      # Open the file dialog box and get the merged file path
  37.      output_file_path = filedialog.asksaveasfilename()
  38.      output_file_entry.delete(0, tk.END)
  39.      output_file_entry.insert(0, output_file_path)


  40. def browse_input_dir():
  41.      # Open the directory dialog box and obtain the split file directory
  42.      input_dir = filedialog.askdirectory()
  43.      input_dir_entry.delete(0, tk.END)
  44.      input_dir_entry.insert(0, input_dir)


  45. #Create the main window
  46. window = tk.Tk()
  47. window.title('File splitting and merging tool')

  48. #File selection box
  49. file_path_label = tk.Label(window, text='Select file:')
  50. file_path_label.pack()
  51. file_path_entry = tk.Entry(window, width=50)
  52. file_path_entry.pack()
  53. browse_file_button = tk.Button(window, text='browse', command=browse_file)
  54. browse_file_button.pack()

  55. # Target size box
  56. target_size_label = tk.Label(window, text='Target size (MB):')
  57. target_size_label.pack()
  58. target_size_entry = tk.Entry(window, width=10)
  59. target_size_entry.pack()

  60. # Split file button
  61. split_button = tk.Button(window, text='Split file', command=split_file)
  62. split_button.pack()

  63. # Merge file box
  64. output_file_label = tk.Label(window, text='Merge files:')
  65. output_file_label.pack()
  66. output_file_entry = tk.Entry(window, width=50)
  67. output_file_entry.pack()
  68. browse_output_file_button = tk.Button(window, text='browse', command=browse_output_file)
  69. browse_output_file_button.pack()

  70. # Split file directory box
  71. input_dir_label = tk.Label(window, text='Split file directory:')
  72. input_dir_label.pack()
  73. input_dir_entry = tk.Entry(window, width=50)
  74. input_dir_entry.pack()
  75. browse_input_dir_button = tk.Button(window, text='Browse', command=browse_input_dir)
  76. browse_input_dir_button.pack()

  77. # Merge file button
  78. merge_button = tk.Button(window, text='Merge files', command=merge_files)
  79. merge_button.pack()
複製代碼
開源的,要用自便

TOP

提示: 作者被禁止或刪除 內容自動屏蔽

TOP