23 jul 2023

find & replace expressions inside a text file running a simple python script in GNU-Linux terminal

FILE 1 (BEGIN)

readMe.txt

································································································

Hi!

This set of files is just a little experiment to do some work over a file with a python script.

File "example.txt" contains expressions that will be replaced with new ones as described on “findAndReplace.py” file in this folder. (there is an “.example.txt” file to have it back again in case you want to. Just make it visible and take the “*.hackUp” fake extension).

See it in action by running the “doAll.sh” batch file as root. Remember to “chmod 755 file2change” to the files if you find it suitable. To install stuff you’ll need internet (o_o)

have fun!

(=

································································································

FILE 1 (END); FILE 2 (BEGIN)

findAndReplace.py

································································································

from pathlib2 import Path
# import some libraries
path = Path("example.txt")                  
# file located in the same folder. tune to your desired route, like /home/user/whatever
text = path.read_text()
# read the file
text = text.replace("=)", ":)")
# replace whatever is necessary
path.write_text(text)
# and finally overwrite the file.

# I had to install...       apt-get install python-pip python3-pip -Y
# & after alsa ...          pip install pathlib2 -Y
# due to                    module not loadad error
# ;-)

# do run from terminal...   python findAndReplace.py


# CC Share alike too the latest! ONLY FOR EDUCATIONAL MEANS!!

································································································

FILE 2 (END); FILE 3 (BEGIN) 

example.txt

································································································

=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)

································································································

FILE 3 (END); FILE 4 (BEGIN)

.example.txt.backUp 

································································································

=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
 

································································································

FILE 4 (END); FILE 5 (BEGIN)

doAll.sh

································································································

#!/bin/bash

apt-get update

apt-get upgrade -y

apt-get install python -y

apt-get install python-pip python3-pip -y

pip install pathlib2

python findAndReplace.py

································································································

FILE 5 (END)

 

# pseudocode is not a crime!


 

10 ene 2023

WinXP - Como acceder a "Opciones de Carpeta" sin pasar por el "Panel de Control"

Debido a causas desconocidas al intentar acceder a Opciones de Carpeta desde el Panel de Control, lo único que consigo es crear un acceso directo en el escritorio inútilmente. El acceso al mismo parece haber sido anulado. No se si de manera fraudulenta o simplemente como un bug o error, pero el caso es que no puedo acceder.

Para ello, lo mejor que pomos hacer ir a Inicio, Ejecutar cmd y escribir en la linea de comando

control.exe folders

Y con esto aparecera nuestra querida ventana con las opciones de carpeta, entre ellas la capacidad de mostrar o dejer ocultos los archivos del sistema. 

Además aquí puedes especificar con que programa abrir cada extensión, por si prefieres por ejemplo abrir un archivo .swf con el navegador de internet por defecto