|
|
|
|
|
import sys |
|
|
import os |
|
|
|
|
|
def convert_to_single_line(input_file, output_file): |
|
|
try: |
|
|
|
|
|
if not os.path.exists(input_file): |
|
|
print(f"Il file '{input_file}' non esiste.") |
|
|
return |
|
|
|
|
|
|
|
|
with open(input_file, 'r', encoding='utf-8') as file: |
|
|
content = file.read() |
|
|
|
|
|
|
|
|
single_line_content = content.replace("\n","\\n ") |
|
|
|
|
|
|
|
|
with open(output_file, 'w', encoding='utf-8') as file: |
|
|
file.write(single_line_content) |
|
|
|
|
|
print(f"File convertito con successo e salvato in {output_file}") |
|
|
except Exception as e: |
|
|
print(f"Si è verificato un errore: {e}") |
|
|
|
|
|
|
|
|
|
|
|
source_file = sys.argv[1] |
|
|
|
|
|
target_file = sys.argv[2] |
|
|
|
|
|
convert_to_single_line(source_file, target_file) |